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

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

Thread Previous | Thread Next
From:
Eirik Berg Hanssen
Date:
August 11, 2018 13:36
Subject:
Re: [perl #133301] Evalulation order during concat changed
Message ID:
22221_1533994601_5B6EE668_22221_33_1_CAHAeAG7L1z+j3mjEOZct2nk=3pmXJvwoESfho3-UCiD_GWKT1A@mail.gmail.com
On Sat, Aug 11, 2018 at 12:58 PM Wolf-Dietrich Moeller (München) <
wolf-dietrich_moeller@t-online.de> wrote:

> Resent because of problems. Sorry
>
> -----Original Message-----
> From: Wolf-Dietrich Moeller (München) [mailto:
> wolf-dietrich_moeller@t-online.de]
> Sent: Samstag, 11. August 2018 10:34
> To: 'perlbug-followup@perl.org'
> Cc: 'Dave Mitchell'; 'Eirik Berg Hanssen'; 'David Nicol'; '
> sisyphus@cpan.org'; 'Dan Book'
> Subject: RE: [perl #133301] Evalulation order during concat changed
>
> David cited the old perlop doc (up to Perl 5.26). This documentation
> was changed in Perl 5.28 and the section on operator precedence and
> associativity was extended quite a lot (see [perl #127391]).
>
> One sentence there reads:
> "In fact Perl has a general rule that the operands of an operator
> are evaluated in left-to-right order."
>
> Eirik, did you consider this new text?
>

  No, sorry; I was unaware of it.

  That might be a game changer.

  Or not; the new text is still pretty vague, and don't strictly match the
behaviour of perl.  I also don't see any discussion of this part of the
patch in the RT ticket ...

  Reading that ticket, I get the impression of a failure to properly
distinguish between (operand) evaluation order and the order in which
_operations_ are evaluated.  I'm sorry I didn't catch that at the time: I
surely would have quibbled.

  This example demonstrates that the left-hand operand is evaluated _after_
the right-hand operand, in violation of this "general rule":

eirik@greencat[15:26:12]~$ perl -E 'say for ($x=1 + say "LHS") = ($x=2 +
say "RHS")'
RHS
LHS
2
eirik@greencat[15:27:56]~$

  ... assuming that did not also change?  (I don't have a new perl here;
currently stuck on vanilla Ubuntu 18.04.1 LTS and it system perl v5.26.1.)

Eirik

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