in reply to Side Context in an 'lvalue' Subroutine

If there is no mechanism presently, is this kind of thing worth implementing as a patch?

I don't know if there's an lvalue-sub way of doing that, but you could turn it all around, and not have a function that is an lvalue, but have an lvalue that is a couple of functions!

That's right, I'm talking about tie.

package Tie::Fooz; sub TIESCALAR { bless \(my $dummy), $_[0] } sub FETCH { ${ $_[0] } } sub STORE { ${ $_[0] } = $_[1] } package main; tie my $foo, 'Tie::Fooz';
Unfortunately, I have not a clue what your code should do or why you would want to use a $foo_new, so I couldn't create an equivalent tie. Anyway, STORE serves as your islvalue condition, and FETCH for not islvalue, I think.

U28geW91IGNhbiBhbGwgcm90MTMgY
W5kIHBhY2soKS4gQnV0IGRvIHlvdS
ByZWNvZ25pc2UgQmFzZTY0IHdoZW4
geW91IHNlZSBpdD8gIC0tIEp1ZXJk

Replies are listed 'Best First'.
Re^2: Side Context in an 'lvalue' Subroutine
by tadman (Prior) on Mar 18, 2002 at 19:19 UTC
    As much as I'm a fan of tie, for this kind of operation it seems to Benchmark abysmally slow, and, additionally, requires a lot of extra effort to impose on a particular scalar. Consider that within an object there may be dozens of variables, each of which would have to be tied independently. Using a single AUTOLOAD lvalue subroutine you could take care of them all, on-demand.

    overload came to mind too, but the assignment ('=') override is a hack at best, though to the credit of the implementor, this is because of Force Majeure, and not lack of initiative or inventiveness.