[Xotcl] Re: serialize usage

Ben Thomasson ben.thomasson at gmail.com
Tue Mar 29 15:35:45 CEST 2005


Gustaf,

It is possible to handle autogenerated names, but maybe not in an
efficient way.   The serializer can walk the object-graph of
associations and build a list of objects that exist in that graph. 
With this list you can provide a mapping from one "reference-space" to
another.  I have written a prototype serializer that handles
associations in this fashion.  It uses an intermediate
reference-space.  Ex.

original        ->       intermediate      ->      new reference-space
::xotcl::__#0 -> ::xoserialize::serial0 -> ::xotcl::__#5

However walking the object graph is somewhat inefficient as I am
looking through the
data for references to objects.  It would be much faster if Object provided an 
info associations, but I am not sure how this could be implemented. 

Because Tcl lacks explicit pointers or references and instead uses
handles which are just strings, serializiation using associations will
be very inefficient.  However can the included serializer which
supports composition handle an arbitrary object graph?  Or am I
restricted to tree structures?

Thanks,

Ben


On Tue, 29 Mar 2005 11:36:24 +0200, Gustaf Neumann
<neumann at wu-wien.ac.at> wrote:
> Dear Aamer,
> 
> the general problem is quite tricky, when one serializes and saves some
> objects
> (e.g. containing ::xotcl::__#0), ends and restarts xotcl, creates again
> global
> objects with 'new' and restores the saved state containing the object
> mentioned
> above. 'Serialize all' does not save objects from the ::xotcl namespace,
> but certainly
> people can use -childof...
> 
> The most simple solution is to remember the highest allocated id with the
> saved state in serialize all, to provide a function to reset it and
> leave the problem
> to the programmer. But still, this is no good solution, if multiple save
> states are
> used and loaded in arbitary order.
> 
> A better solution is to
>   a) check in 'new', whether an object with the generated autoname
> exists already, and
>   b) provide a wrapper for loading the serialized code that extracts all
> patterns
>       of autonames, and remaps some or all symbols if necessary (for
> handling preexisting
>       objects with autonames). This could be done by searching for
> autoname patterns
>       during serialization and using similar to the -map option of the
> Serializer....;
>       but still, this only works, when the autonamed objects are
> serialzed; for references
>       in variables we would need a global map table, which is still
> depending on the
>       restore order of the serialized code if multiple pieces are saved.....
> 
>  What are you trying? would (a) be sufficient for you? It is slightly
> slower than the
>  current version, but i don't think it is worth adding another option to
> new for checking
>  on demand...
> 
> best regards
> -gustaf neumann
> Aamer Akhter schrieb:
> 
> >I just tried this with 1.3.6 and it appears to be working. Sort of
> >related question, how do people handle the swizzling/unswizzling of
> >autogenerated object names (eg ::xotcl__#0) when restoring an object?
> >
> >
> 
> _______________________________________________
> Xotcl mailing list
> Xotcl at alice.wu-wien.ac.at
> http://alice.wu-wien.ac.at/mailman/listinfo/xotcl
>


More information about the Xotcl mailing list