develooper Front page | perl.perl5.porters | Postings from July 2011

Re: Why views are useful, and why their syntax doesn't matter much

Thread Previous | Thread Next
From:
Aristotle Pagaltzis
Date:
July 10, 2011 17:54
Subject:
Re: Why views are useful, and why their syntax doesn't matter much
Message ID:
20110711005413.GV8585@klangraum.plasmasturm.org
* Father Chrysostomos <sprout@cpan.org> [2011-07-11 02:20]:
> I can’t speak for Perl 6, but making something read-only in
> Perl 5 just feels un-Perl-5-ish. After all, we allow $^X
> assignment.

Heck it was only recently agreed that

    for (1,2,3) { ++$_; say }

should not complain about “modification of read-only value” nor
change the values in the optree but instead give you modifiable
copies. Arguably that is what one would expect to happen there
in the first place.

> If you want something more efficient than copying, we have
> copy-on-write for strings. Can we make perl use that more
> often? And isn’t copying an RV or a number just as fast as
> making a view?

Yes, I believe `my ($arg, $um, $ents) = @_` already has perfectly
sensible semantics that should be replicated by whatever syntax
becomes the default. If it can yield better performance too (as
defaulting to CoW would allow), all the better, but that should
not be the primary concern. As for aliases, anyone who wants one
should just be able to ask for one explicitly, along the lines of
`my (\$arg, $um, $ents) = @_` per the backslash-in-lvalue-context
proposal.

Regards,
-- 
Aristotle Pagaltzis // <http://plasmasturm.org/>

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