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

Re: announcing a new op, OP_MULTICONCAT

Thread Previous | Thread Next
From:
Dave Mitchell
Date:
November 4, 2017 12:05
Subject:
Re: announcing a new op, OP_MULTICONCAT
Message ID:
20171104120539.GE6041@iabyn.com
On Fri, Nov 03, 2017 at 11:35:28AM +0100, demerphq wrote:
> > From perlop:
> >
> >     Assignment operators work as in C.  That is,
> >
> >         $x += 2;
> >
> >     is equivalent to
> >
> >         $x = $x + 2;
> >
> >     although without duplicating any side effects that dereferencing the
> >     lvalue might trigger, such as from C<tie()>.  Other assignment
> >     operators work similarly.
> >
> > So they're not quite the same.
> 
> That comment goes back to the
> a0d0e21ea6ea90a22318550944fe6cb09ae10cda, the 5.000 patch.
> 
> Personally I read that as documenting what we do, not that it is correct.

I see it as emphasising that $x will only be evaluated once, and that this
is intentional. For example

    my $s = "abc";
    sub f : lvalue { print "In f()\n"; $s }
    f .= "def";

only calls f() once.

> Isn't that non-obviousness a byproduct of the "12" vs "4123" discrepancy?
> 
> It seems to me that if this behavior was well defined then both this
> question and the discrepancy would go away.

From my experience of working on multiconcat, I think it would be a very
hard task to form a well-defined list of behaviours for all the
interactions of tie, overload, number of uninit warnings, etc.

-- 
The Enterprise successfully ferries an alien VIP from one place to another
without serious incident.
    -- Things That Never Happen in "Star Trek" #7

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