develooper Front page | perl.perl5.porters | Postings from January 2001

Re: `Final' lvsub patch: arrays and hashes

Thread Previous | Thread Next
From:
Simon Cozens
Date:
January 7, 2001 09:19
Subject:
Re: `Final' lvsub patch: arrays and hashes
Message ID:
20010107131438.A1362@pembro26.pmb.ox.ac.uk
On Fri, Jan 05, 2001 at 10:10:54AM -0800, Stephen McCamant wrote:
> I'm calling mod(). The whole point of mod() is to check at compile
> time that its argument is an lvalue.

You're going too far, then. The point of your calling mod is to isolate
arrays, hashes, elements and slices which are returned from lvalue subs
to mark their behaviour as special for when you come to look at them at
run time. No over ops should be affected by this!

> If you like being able to assign to shift, I'd like to hear an argument why.

I'm not assigning to shift, I'm assigning to the return value of the
subroutine. The documentation says it is possible to return a modifiable value
from a subroutine: sub foo : lvalue { shift } returns $_[0].
I consider these to be equivalent:

    sub foo { $_[0] = 7; }   foo($a)
    sub foo :lvalue {shift}  foo($a) = 7 
 
-- 
People in a Position to Know, Inc.

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