By placing it into the scalar slot associated of the typeglob of the functions name.
That's not so good - you run the risk of clobbering something. Doing an implicit 'local' might help, but what do you do with lvalue-able anonymous subs?
*^_ is a much better idea, imho. And, I'd just have it go to @^_ straight off. That way, it would act as a standard assignment does. $foo = 1..3; anyone?
(FYI - it's mnemonic, not pnemonic ... you want memory, not the plague.)
Being right, does not endow the right to be rude; politeness costs nothing. Being unknowing, is not the same as being stupid. Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence. Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.
| [reply] [d/l] |
| [reply] |
I thought about that too but one problem is order of evaluation. In order to provide the rvalue to the sub, you would have to evaluate the right hand side before the left hand side and that's odd or possibly even bad (I'm not exactly sure yet).
I've also seen Larry Wall say somewhere that tieing is the way you will have to do this in Perl 6 (although it will be considerably more straight forward that in Perl 5)
| [reply] |
...you would have to evaluate the right hand side before the left hand side...
I'm not sure that I understand you. The right-hand side of an assignment is always evaluated before the assignment can occur? Except maybe in the case of assigning a constant, but even then the value of that constant is fetched from wherever before it can be assigned to the lvalue.
It's quite possible that I do not fully grasp the purpose or magic that lies behind the implementation of lvalue subs, but any code in an lvalue sub is invoked as a sideeffect of the assignment to an lvalue sub:
{ my $x; sub x: lvalue { print 'fred'; $x } };
x = 123;
fred
The problem is that you can't do anything useful with that code as you cannot affect the outcome of the assignment relative to the value being assigned.
Examine what is said, not who speaks.
Silence betokens consent.
Love the truth but pardon error.
| [reply] [d/l] |
Yes, that part was nonsense, sorry about that. However Larry has officially declared tie as the way to do it for other reasons (see my reply to LR above).
| [reply] |
By placing it into the scalar slot associated of the typeglob of the functions name.
You can't. It has already been taken by AUTOLOAD.
| [reply] |