The stupid question is the question not asked | |
PerlMonks |
Re: Class::InsideOut - yet another riff on inside out objects.by Aristotle (Chancellor) |
on Dec 19, 2002 at 16:15 UTC ( [id://221145]=note: print w/replies, xml ) | Need Help?? |
In general, I like your approach - a lot. One thing that annoyed me is the $self->self meme. Confusing, IMO, and not efficient either. I toyed around with the idea of wrapping subs in some way, but haven't come up with any really consistent and watertight semantics. :-/ The only possibility would be to tie all field hashes to a class that autocasts any refs used as keys into their refaddr before using them but that doesn't perform any better. Overloading the stringification on the reference might help, but will neither perform better nor work reliably if someone else overloads the same operation. So there really seems to be no other way than to remind everyone to use $self->self everywhere. Though I'd probably call that $self->_id instead. Or maybe an attribute Self? Not sure yet.. gonna have to look into that. That aside, here's my take on the base class - minus refaddr cause it doesn't work on 5.6.1. What I do is quite simple: store the hashref to the pad :-). Then all that AUTOLOAD has to do is trawl through the pad hashrefs and look for a matching attribute. And some test code: I don't know if it's watertight, though. In particular, how well will it work if I call an accessor for a superclasses' field on a subclass? Makeshifts last the longest.
In Section
Meditations
|
|