develooper Front page | perl.perl5.porters | Postings from January 2017

[perl #4514] two bugs: substitution on a list

Thread Previous | Thread Next
From:
Sawyer X via RT
Date:
January 2, 2017 14:28
Subject:
[perl #4514] two bugs: substitution on a list
Message ID:
rt-4.0.24-24772-1483367250-1940.4514-15-0@perl.org
On Mon, 02 Jan 2017 05:26:57 -0800, jkeenan wrote:
> On Sun, 08 Sep 2013 05:25:23 GMT, sprout wrote:
> > On Sat Sep 07 02:21:21 2013, davem wrote:
> > > On Fri, Sep 06, 2013 at 07:24:44PM -0700, James E Keenan via RT
> > > wrote:
> > > > > On Wed Oct 25 08:41:02 2000, hv@crypt.compulink.co.uk wrote:
> > > > > > (After a report in clp.moderated from Peter Scott
> > > > > > <peter@psdt.com>.)
> > > > > >
> > > > > > perl -Dr -we '(($y) = "x") =~ s/a/b/'
> > > > > >
> > > > > > shows that a) perl is trying to perform the substitution on
> > > > > > the
> > string
> > > > > > '1' which is not what the caller intended, and b) '1' is not
> > > > > > marked
> > > > > > readonly in this context, so no error is reported. I think
> > > > > > both of
> > > > > > these are bugs: I think the former should be fixed by giving
> > > > > > an
> > error
> > > > > > if the LHS of a binding operator is supplied as a list, and
> > > > > > that the
> > > > > > latter should be fixed (if still relevant) by marking the
> > > > > > count of
> > > > > > list elements as readonly.
> > >
> > > I don't think either of these are bugs.
> > >
> > > In the first instance, its a list assignment evaluated in scalar
> > > context,
> > > which is well-defined as returning the number of elements assigned.
> > > The result may be slightly unexpected to the uninitiated, but its
> > > no
> > > different than say
> > >
> > > $count = (($y) = "x");
> > >
> > > which sets count to 1.
> > >
> > > In the second instance, (($y) = "x") in scalar context is an
> > > expression
> > > that returns a well-defined numeric value. I see no rationale for
> > > it
> > > to be read-only, any more than any other expression should return a
> > > read-only value.
> >
> > Hmm, but should aassign be allowed as a scalar lvalue?
> >
> > We also allow:
> >
> > read STDIN, @a=qw(foo bar), 10
> >
> > Should we?
> >
> > (I wrote earlier that I agreed.  Now I’m not sure.  Reopening....)
> >
> 
> More than 3 years later there has been no support for this idead --
> indeed, no further comment in this RT.  So I recommend we re-close it.

I recommend we seek affirmation to closing this from either Dave or Father C.

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=4514

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