develooper Front page | perl.perl5.porters | Postings from September 2009

Re: A complete design for := (bind)

Thread Previous | Thread Next
From:
Daniel Ruoso
Date:
September 3, 2009 17:33
Subject:
Re: A complete design for := (bind)
Message ID:
1252024492.7624.102.camel@cajueiro
Em Sáb, 2009-08-29 às 14:22 +0100, Ben Morrow escreveu:
> > >     sub foo(\$a, \@b) { ... } # aliasing
> > >     sub foo($a, @b) {... } # copying
> First: I don't like the ro-alias default at all. I would much prefer a
> cow-alias: for one thing, it's not at all clear how 'deep' the
> readonlyness should go.

I've said this in other message to this thread, but it applies here as
well. The is-ro is-rw in the signature makes a lot of difference for
Perl6 because of the extremely clear split between the value and the
container. In Perl 6 it's the container that is made rw, so that if you
store another value in that container, it will modify the variable
outside the routine.

In the case of perl5 that semantic is a bit different since there's no
distinction between the value and the container. So you can't provide a
read-write scalar that is not modifying the outer scope unless you make
a copy of that scalar. Having it changing the caller variable by default
is kinda weird, hence the ro-alias default.

daniel



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