Since you're getting 1.1 ready...
I ran across a very, very subtle bug. I was using the serializer to serialize an obj tree. The topological sorting wasn't quite working for one case. In the end, I tracked it down to the fact that I was passing in an unqualified name. The sorting routine was in turn using fully qualified references as it tried to build the correct ordering, and the mismatch meant that it got some orderings for the root object slightly wrong. (Basically a few objects were being created before their containers; their containers were objects aggregated by the root object.)
In effect, I was using this:
Serializer deepSerialize obj
when I should have been using this:
Serializer deepSerialize ::obj
I don't think you'd be able to reproduce this easily, because it turned out to relate to a specific set of objects and relationships. It turns out that for other reasons, even when you make this "mistake" the algorithm nearly works.
To make this work you'd either have to a) require fully qualified names or b) turn a name into a fully qualified name. I don't know enough about Tcl internals to say that (b) is a realistic option--but on the face of it it doesn't seem like it would be.
Don't know if this helps much. :-)
This is rather an unexpected behavior than a bug ... I think it would be ok, to force a full name for serialize and deepSerialize, that is, change the method in Serializer.xotcl to:
Serializer instproc serialize {objectOrClass} { my [my category $objectOrClass]-serialize [$objectOrClass] }
can you please check whether that would work in your example?
--uwe
On Tuesday 16 September 2003 22:34, MichaelL@frogware.com wrote:
Since you're getting 1.1 ready...
I ran across a very, very subtle bug. I was using the serializer to serialize an obj tree. The topological sorting wasn't quite working for one case. In the end, I tracked it down to the fact that I was passing in an unqualified name. The sorting routine was in turn using fully qualified references as it tried to build the correct ordering, and the mismatch meant that it got some orderings for the root object slightly wrong. (Basically a few objects were being created before their containers; their containers were objects aggregated by the root object.)
In effect, I was using this:
Serializer deepSerialize obj
when I should have been using this:
Serializer deepSerialize ::obj
I don't think you'd be able to reproduce this easily, because it turned out to relate to a specific set of objects and relationships. It turns out that for other reasons, even when you make this "mistake" the algorithm nearly works.
To make this work you'd either have to a) require fully qualified names or b) turn a name into a fully qualified name. I don't know enough about Tcl internals to say that (b) is a realistic option--but on the face of it it doesn't seem like it would be.
Don't know if this helps much. :-)
No, that didn't work. I verified that a) my code with the qualified name worked and b) if I removed the qualification it didn't work and c) if I added your change it still didn't work.
With some effort I can strip down my code to just give you the essentials. For what it's worth, here are the first few lines of the broken serialized file:
::Collection create ::agenda::items -noinit -array set __autonames {Item 11} ::Collection create ::agenda::categories -noinit -array set __autonames {Category 2} ::mulAgenda::Agenda create ::agenda -noinit ::Collection create ::agenda::views -noinit -array set __autonames {View 1} ...
You can see that lines 1 and 2 are creating objects that are aggregated inside ::agenda--but ::agenda isn't created until line 3. If I fully qualify the name I get what you'd expect:
::mulAgenda::Agenda create ::agenda -noinit ::Collection create ::agenda::items -noinit -array set __autonames {Item 11} ::Collection create ::agenda::categories -noinit -array set __autonames {Category 2} ::Collection create ::agenda::views -noinit -array set __autonames {View 1} ...
However, Michael Schlenker's idea worked. I changed this:
Serializer instproc deepSerialize o { my serializeList [my allChildren $o] }
to this:
Serializer instproc deepSerialize o { my serializeList [my allChildren [namespace which $o]] }
Would such a change be required anywhere else?
Uwe Zdun uwe.zdun@wu-wien.ac.at wrote on 09/17/2003 04:44:00 AM:
This is rather an unexpected behavior than a bug ... I think it would be ok, to force a full name for serialize and deepSerialize, that is, change the method in Serializer.xotcl to:
Serializer instproc serialize {objectOrClass} { my [my category $objectOrClass]-serialize [$objectOrClass] }
can you please check whether that would work in your example?
--uwe