On 2008-Jun-1, at 1:50 pm, Jon Lang wrote:
David Green wrote:
[...] assignment should work like passing args when used on a function. Then you can easily do whatever you want with it.
If a routine is rw, you may optionally define a single "slurpy scalar" (e.g., '*$value') in its signature. This scalar counts as the last positional parameter, much like slurpy arrays and hashes must be declared after all of the positional parameters have been declared. You do not need to pass an argument to it; but if you do, you may do so in one of two ways: through the usual arguments syntax, or via assignment syntax.

The only objection I have to making it a positional parameter is that then you can't have other optional positionals before it. (Also, doesn't the '*$value' notation conflict with a possible "head" of the slurpy array?)

I'd rather make it named so it doesn't interfere with other args. Or have it separate from named/positional args altogether; if something has a meaning of assignment, then it should always look like "foo = 42" and not like "foo(42)". (The latter is just an ugly workaround for languages with incompetent syntax -- we don't want Perl code to look like that because Perl isn't like that.)

If an assignable routine does not have a slurpy scalar in its signature, it operates exactly as currently described in S06: it returns something that is assignable, which in turn is used as the lvalue of the assignment operator.

Does this [with no slurpy scalar to pick up the rvalue]:

    sub foo () { ...; $proxy }

give us anything that you couldn't get from:

    sub foo ($rval is rvalue) { ...; $proxy = $rval }

[...] sub foo () is rw {
   return new Proxy:
     FETCH => method { return .() },
     STORE => method ($val) { .($val) },
     postcircumfix:<( )> => method ($value?) { yadda }

Incidentally, now that Perl is all OO-y, do we need tying/proxying like that, or can we just override the "=" method on a class instead? Is there something different about it, or is it just an alternative (pre-OO) way of looking at the same thing?


Reply via email to