http://qs1969.pair.com?node_id=1150137


in reply to Re^2: Declaring with my, assigning, and testing in same line (attributes)
in thread Declaring with my, assigning, and testing in same line

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.

update

seems liked I didn't realy understood Tie::StdScalar yet

update
this approach with autotieref

use Attribute::Handlers autotieref => { Selfish => Tie::Selfish };

should provide the necessary reference to the tied structure, so that untieing becomes possible.

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!