On Aug 16,  8:21pm, Perl6 RFC Librarian wrote:
>   # this is perl6
>   sub foo :lvalue ($new) {
>     $variable = $new;
>   }

A nice idea, but one of the reasons for the original proposal was
to make

  $foo->bar = $x;

behave the same as:

  $foo->bar($x);

Your proposal provides a neat solution for lvalues, but at the cost of
the original aim (or my aim, at least).  If you wanted to accept either
of the above then your code would end up looking something like this:

    sub foo($argnew) : lvalue($rvalnew) {
        $variable = want('lvalue') ? $rvalnew : $argnew;
    }

I think that's likely to make things more complicated in the long run.

I'm inclined to say that assignments of the form:

    $foo->bar(@baz) = @boz;

Are allowed, but just plain stupid. It's the same as:

    $foo->bar(@baz, @boz)

and you're right, Perl can't tell the lvalues and rvalues apart.  So
don't do that.  If we can fix Perl so that it can tell the above
apart, then good, but I think it's a separate problem to the lvalue
subs.



A


-- 
Andy Wardley <[EMAIL PROTECTED]>   Signature regenerating.  Please remain seated.
     <[EMAIL PROTECTED]>   For a good time: http://www.kfs.org/~abw/

Reply via email to