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

Re: A complete design for := (bind)

Thread Previous | Thread Next
From:
Chip Salzenberg
Date:
August 25, 2009 17:20
Subject:
Re: A complete design for := (bind)
Message ID:
20090825235954.GJ12655@tytlal.topaz.cx
On Tue, Aug 25, 2009 at 07:30:31PM -0400, David Golden wrote:
> I agree on the decoration point.  So you want this, with all aliases
> being read-only:
> 
>     sub foo( $a, @b, %c ) { ... }
>     # $a is an alias, @b contains aliases to remaining arguments, %c is empty
> 
>     sub foo( $a, \@b, %c ) { ... }
>     # $a is an alias, @b is an alias to an array argument, values in %c are aliases

Yup, the above looks good.

> I'm not sure I like the idea of introducing read-only by default just
> because it's so different from how things work today, where @_ is a
> read-write alias.

The actual current practice is always to make copies via assignment
e.g. C<my ($a,@b) = @_>.  A read-only alias is as safe as copies but more
efficient.  And remember @_ will still be there.  So it's not such a
problem.

> I don't terribly mind traits in a signature.  I do mind them in the body
> of the code since they look like bareword function calls but aren't (in
> this context anyway).  I'd be annoyed to see "is rw" in Moose declarations
> and in signatures and elsewhere in code and have them executing through
> very different mechanisms.

I'm not sure why that should be annoying.  In both cases, "is rw" means "is rw".
-- 
Chip Salzenberg

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