Just another Perl shrine | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I'm disappointed that you chose to leave out the heart of your idea, how ego() works.
Sorry. That can be helped :) ego($obj, $alter) sets the alter ego of $obj to be $alter. When called with one argument, ego($obj) retrieves whatever $alter was in the two-argument call. The point in this is that ego() is caller-sensitive, so that each class sees its individual Alter::ego() for each object. A class can initialize it to whatever it wants and use it without interference from other classes. No other class can access it (through the official interface), by definition. In the current implementation the assignment is sticky, it only works once for each class/object combination, but I don't think that's necessary. In more detail, on the first call (ever) with an object, ego() associates one hash with the object (through ext magic), which is keyed by the caller's class name to store the individual alter ego(s). Later calls from other classes continue to use it. I like to call this hash the corona because it represents the round of alternative personalities of an object, to stay with the image, and also because it is the overhead. The corona is invisible to the normal class user, but will be made internally available to support serialization through Data::Dumper and Storable. Anno In reply to Re^2: Beyond Inside-Out (fluff)
by Anno
|
|