A quick idea. Instead of storing cells directly in the data structure
could you replace them with indices into a separate array instead? Of
course you will need to change all your code that accesses/updates the
cells.
k
Wolfgang Meyer writes:
> Dear all,
>
> I need some advice on how to pickle a recursive data structure that may
> contain cells.
> I know that the Pickle module only works for stateless data, so I thought
> I'd write a small conversion function that I call before the call to
> Pickle.save. And a similar function to apply after Pickle.load.
>
> The conversion function would look like this:
>
> declare
>
> CellMarker = 'unique-string-marking-cells'
>
> fun {ConvertToStateless D}
> if {Record.is D} then
> {Record.map D ConvertToStateless}
> elseif {Cell.is D} then
> CellMarker#{ConvertToStateless @D}
> else
> D
> end
> end
>
>
> The problem is that this function diverges on cyclic records, like
>
>
> A = test(1:A)
> in
> {ConvertToStateless A}
>
>
> Any idea how I could make this work for such records?
>
> I guess I need to detect cycles in some way. Maybe there is some existing
> code in the standard library that can show me the way?
>
> Thank you for any hints,
>
> Wolfgang
>
> --
> Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
> Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
>
> _________________________________________________________________________________
> mozart-users mailing list
> [email protected]
> http://www.mozart-oz.org/mailman/listinfo/mozart-users
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users