A Conceptual Question
Denys Duchier
Denys.Duchier at ps.uni-sb.de
Tue Apr 30 00:51:53 CEST 2002
phreed at netarx.com (Fredrick Paul Eisele) writes:
> Could you give me some idea how difficult writing a perl pickler (is
> that the right name?) would be? Based on your experience with
> alice, that is.
The experience with Alice has nothing particular to say about pickling
except that runtime typechecking incurred when linking a pickled
structure is not entirely straightforward to optimize.
Non-statically typed languages don't have to worry about this issue.
The only mildly challenging issue with pickling is when you want to
preserve sharing. This is essential for Mozart and I imagine also for
Perl in the presence of "references" which can create cycles.
The design of a pickler/unpickler is pretty much always the same. The
pickler recursively traverses the datum to be pickled, and, for each
value encountered, outputs (1) an opcode corresponding to the type of
the current value, (2) a pickled representation of its
subvalues/args. The unpickler is just a virtual machine interpreting
the code output by the pickler.
I frequently use a stack-machine approach, which means I generate
postfix code in the pickler. However you can just as well also use a
prefix approach (this is what is done in the Mozart marshaler).
Cheers,
--
Dr. Denys Duchier Denys.Duchier at ps.uni-sb.de
Forschungsbereich Programmiersysteme (Programming Systems Lab)
Universitaet des Saarlandes, Geb. 45 http://www.ps.uni-sb.de/~duchier
Postfach 15 11 50 Phone: +49 681 302 5618
66041 Saarbruecken, Germany Fax: +49 681 302 5615
-
Please send submissions to users at mozart-oz.org
and administriva mail to users-request at mozart-oz.org.
The Mozart Oz web site is at http://www.mozart-oz.org/.
More information about the mozart-users
mailing list