Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re^4: Can I serialize an object and have it remember it's type?

by Anonymous Monk
on Jul 22, 2005 at 12:43 UTC ( #477203=note: print w/replies, xml ) Need Help??

in reply to Re^3: Can I serialize an object and have it remember it's type?
in thread Can I serialize an object and have it remember it's type?

Minor correction: object state serialization works for any blessed type in Perl, not just references to hashes.
For what part of
for instance, that objects are implemented using a reference to a hash, and that the entire state of the object depends only on the content of said hash (or reference to an array, or scalar).
is that a minor correction?
But state serialization is, as the name implies, writing the state of the object, not the state of the package which manages the object.
An object in Perl is nothing more (and nothing less) than a blessed reference. Fly-weigth and inside-out objects are just that, blessed references. But in general, when people want to "serialize" an object, they want more than the reference, and the package it was blessed into. They also want whatever is used to keep the state of that object.
If you want to implement a new object model on top of the one Perl has got already, including flyweight or inside-out,
Fly-weight and inside-out objects don't implement a "new moduel on top of the one Perl has got already". What Perl has is bless REFERENCE, PACKAGE. Traditional hash based, fly-weight and inside-out objects use blessed references. Where fly-weight and inside-out differ from traditional objects is that traditional objects use the memory the reference is pointing to store their state, while fly-weight and inside-out use the reference as an index. But neither solution is any more or less "native" to Perl, as the language support for objects stops after bless.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://477203]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2021-01-25 01:51 GMT
Find Nodes?
    Voting Booth?