2009/11/25 David Golden <xdaveg@gmail.com>:
> On Wed, Nov 25, 2009 at 3:33 PM, Abigail <abigail@abigail.be> wrote:
>> I've written code in past like this:
>>
>> for (1 .. 3) {
>> $_ .= "foo";
>> say;
>> }
>
> Yes, but if that was (1,2,3), it would fail. E.g., currently:
>
> $ perl -E 'for (1, 2, 3) { $_.="foo"; say }'
> Modification of a read-only value attempted at -e line 1.
>
> $ perl -E 'for (1 .. 3) { $_.="foo"; say }'
> 1foo
> 2foo
> 3foo
>
> So I think making constant *range* act like a constant *list* is
> "fixing a bug" not "breaking a feature".
I'd rather have it the other way around : make the for(1,2,3) variant
work, with some sort of copy-on-write.
Thread Previous
|
Thread Next