develooper Front page | perl.perl6.language | Postings from June 2005

Re: scalar dereferencing.

Thread Previous | Thread Next
From:
Joshua Gatcomb
Date:
June 17, 2005 12:29
Subject:
Re: scalar dereferencing.
Message ID:
941eab840506171229281043c3@mail.gmail.com
On 6/17/05, Larry Wall <larry@wall.org> wrote:
> On Fri, Jun 17, 2005 at 03:56:50AM +0800, Autrijus Tang wrote:
> :
> :     my $x = 3;
> :     my $y = \$x;
> :     say $y + 10;
> :     $y++;
> :     say $y;
> :     say $x;
> :

> I suspect people will find that counterintuitive.  A more consistent
> approach might produce
> 
>     13
>     14
>     14
> 
> That is, if + deferences automatically, so should ++, such that the
> "thingie" pointed to by both $x and $y is what gets incremented,
> not a clone of it.  It should take more work than that to get a COW
> reference, I suspect.

Ok - but where does the assignment come in?  The only change to $y is
in $y++ so I would think the results should be
13
4
4

> 
> Larry
> 

Cheers,
Joshua
a.k.a. L~R

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