develooper Front page | perl.perl5.porters | Postings from August 2018

Re: [perl #133301] Evalulation order during concat changed

Thread Previous | Thread Next
From:
Dave Mitchell
Date:
August 10, 2018 17:56
Subject:
Re: [perl #133301] Evalulation order during concat changed
Message ID:
19839_1533923779_5B6DD1BE_19839_44_1_20180810175558.GJ2798@iabyn.com
On Fri, Aug 10, 2018 at 06:24:56PM +0200, Wolf-Dietrich Moeller (Munchen) wrote:
> $e = 'ab'; $f = 'cd'; $x = $e.$f.($f = 'FF');print '$x = '.$x;
> 
> $x = abcdFF     #### up to Perl 5.26
> $x = abFFFF     #### in Perl 5.28.0

> As 'concat' operation is left-associative (see perlop-documentation),
> first $e.$f is evaluated. As second step the following bracket
> is evaluated, assigning 'FF' to $f. As third step the second
> concat is evaluated.

The issue here is what order (if any) does perl guarantee sub-expressions
to be evaluated? For example in

    ($a+$b) * ($c*$d)

does perl guarantee that the first addition will take place before the
second addition? I think the answer is no, although I'm willing to be
proved wrong. If not, then multiconcat has only changed undefined
behaviour.

-- 
Diplomacy is telling someone to go to hell in such a way that they'll
look forward to the trip

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