Don't ask to ask, just ask | |
PerlMonks |
Re^3: Declaring with my, assigning, and testing in same line (attributes)by LanX (Saint) |
on Dec 12, 2015 at 21:24 UTC ( [id://1150137]=note: print w/replies, xml ) | Need Help?? |
Thanks I started experimenting myself after you messaged me. As said you'll need to tie cause Attributes happen at compile time and you have to intercept the assignment in STORE. (didn't know about EXTEND till now) I'm fine with using tie as long as I can untie when I'm done. Otherwise the penalty for this syntactic sugar would be to huge. I took a simpler case, tieing a scalar, and trying to use untie $$self within STORE {}. Didn't work. (probably because dereferencing isn't allowed for untie or scope restrictions) IMO as long we can't automatically untie, this approach shouldn't be used.
updateseems liked I didn't realy understood Tie::StdScalar yet
updatethis approach with autotierefuse Attribute::Handlers autotieref => { Selfish => Tie::Selfish }; should provide the necessary reference to the tied structure, so that untieing becomes possible.
Cheers Rolf
In Section
Seekers of Perl Wisdom
|
|