
abigail at abigail
Nov 25, 2009, 12:33 PM
Post #5 of 18
(575 views)
Permalink
|
|
Re: [PATCH] Perl RT#3105 Mark elements of constant range as read only
[In reply to]
|
|
On Wed, Nov 25, 2009 at 11:17:04AM -0500, Eric Brine wrote: > On Wed, Nov 25, 2009 at 3:26 AM, Abigail <abigail [at] abigail> wrote: > > > On Tue, Nov 24, 2009 at 07:52:38PM -0500, Eric Brine wrote: > > > Hi, > > > > > > This makes 1..5 no different than 1,2,3,4,5 in terms of functionality, > > and > > > avoids some very subtle bugs. > > > > > > > > > It does however have the potential to break code. > > > > Yes. Specifically, it'll break code (noisily) that modifies what Perl treats > as constants. I even had to fix such a bug in t/op/mydef.t. This is what the > submitter and the responders requested. If you'd rather I do it differently, > I'm up to giving it a go. I've no suggestion to do it differently. I'm just pointing out the patch comes with a price - it may break code. I've no opinion on whether that price is one we want to pay. I've written code in past like this: for (1 .. 3) { $_ .= "foo"; say; } __END__ 1foo 2foo 3foo which just DWIM. I'd be surprised if others haven't done so either, be it on purpose, or by accident. OTOH, I had code that broke when map {s/.//; $_} "ab", "bc", "cd"; no longer was possible, and that breakage didn't stop progress from happening. But that was 10 years ago, and peoples opinion on backwards compatability have changed. I've never been happy with the restriction of not being able to modify values - the fact the values are marked read-only is an implementation issue - and I prefer programmers not to be hindered by implementation issues. Abigail
|