P is for Practical | |
PerlMonks |
Re^3: Garbage collected class attributes with inside out classes.by Anno (Deacon) |
on Mar 01, 2007 at 18:46 UTC ( [id://602749]=note: print w/replies, xml ) | Need Help?? |
Those are valid concerns, at least in the context of a one-off implementation. If you think of it as (say) an additional feature of Class::Std, the choice of the "representative attribute" would be abstract (probably the first, or last, attribute declared in the class) and rather obvious. The ugliness would be hidden in the general destructor.
Come to think of it, there's a problem with classes that don't have (their own) object attributes, but still want destructible class data. Normal garbage collection would likely ignore such a class, so it can't be used as a trigger. You'd need a dummy attribute or some such. Your more intricate first implementation would still work, if only because the class attributes are implemented as object attributes, so the case doesn't arise. Unrelatedly, I think your writeup would be easier to read if you swapped the two implementations, so the simple one comes first and can serve as an introduction. Anno
In Section
Meditations
|
|