Re: RFC 132 (v3) Subroutines should be able to return an lvalue

[email protected] ((Johan Vromans)) 30 Aug 2000 16:57:47 +0200
Newsgroups perl.perl6.language.subs
Message-ID <[email protected]>
Nathan Wiger <[email protected]> writes:

>    $cgi->param($var) = @val;
>    $cgi->param($var, @val);

You can do that easily:

  sub param {
    my ($self, @rest) = @_;
    $self->{aval} = @rest if @rest;     # See note
    lreturn $self->{aval};
  }

Note that no assignment in line "# See note" will take place if the
method is called without additional parameters.

My point is that a call like "$cgi->param($var) = @val" may not be
considered mere syntactic sugar for "$cgi->param($var, @val)". It is
much more.

-- Johan