perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jean-Michel Hiver" <>
Subject Re: transient object data
Date Sun, 23 Dec 2001 11:51:00 GMT
> By attribute do you mean an element of the data structure that is blessed
> in the object? Or do you mean some sort of new attribute you would assign
> new Serializable data type (ala something to suggest for Perl 6).

I think that what Brian was trying to say is that you could mark an object
attribute as being transient and Data::Dumper would ignore it.

Maybe the way to do it would be to have a Serializable class that could have
the following methods:

freeze($self) : SCALAR
thaw ($class) : OBJECT
clone($self) : OBJECT;
_freeze($self): SCALAR

The transient attributes names could be stored in @TRANSIENT.
Maybe we could also have a more generic $TRANSIENT coderef as well.

Whenever you want to serialize an object calling freeze, then the object is
cloned and the clone gets its transient attributes removed. That we can call
_freeze on the modified copy.

With this interface it would be possible to subclass Serializable with
Serializable::FreezeThaw, Serializable::DataDenter or
Serializable::XMLDumper for instance (just override the _freeze and thaw
methods). The objects can also redefine the clone() method if they need to.

Now there's only one drawback that I can see - It needs to be written :-)

Jean-Michel Hiver.

View raw message