develooper Front page | perl.perl6.language.subs | Postings from August 2000

Re: RFC 118 (v1) lvalue subs: parameters, explicit assignment, and wantarray() changes

Thread Previous | Thread Next
From:
JVromans
Date:
August 17, 2000 10:16
Subject:
Re: RFC 118 (v1) lvalue subs: parameters, explicit assignment, and wantarray() changes
Message ID:
m2og2rzumv.fsf@phoenix.squirrel.nl
Nathan Wiger <nate@wiger.org> writes:

> Most of the places I've seen them used really well is if
> they walk and talk like other forms:
> 
>    $cgi->param($var, @val);      # traditional
>    $cgi->param($var) = @val;     # lvalue, but same thing

I do not think this is critical. When lvalue subs catch on, the
traditional way will soon be extinct.

However, if an lvalue sub is an lvalue, it must be an lvalue in _all_
respects. 

    $cgi->param($var) = ...
    $cgi->param($var) += ...
    $cgi->param($var) =~ s///
    for ( $cgi->param($var) ) {
        $_ = ...
    }
    sysread($fh,$cgi->param($var),...)

and so on.

And, what would the lvalue routine return? Currently, $a = $b = $c
implies that both $b and $a get the value $c. But with lvalue subs I
can write something like

    yech($foo) = $bar

that assigns $bar to $foo, and returns something else (e.g., the
previous value of $foo). 

    $a = yech($foo) = $bar

now $a will no longer get $bar assigned.

Do we want that?

-- Johan



Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About