develooper Front page | perl.perl5.porters | Postings from July 2010

Re: [perl #76438] peephole optimiser could prune more dead code

Thread Previous | Thread Next
From:
Eric Brine
Date:
July 13, 2010 15:25
Subject:
Re: [perl #76438] peephole optimiser could prune more dead code
Message ID:
AANLkTimjNWISSV3CdZbN8BDsQ_xEFoK1MNFbR4i6pkpS@mail.gmail.com
On Tue, Jul 13, 2010 at 1:55 PM, Ben Morrow <ben@morrow.me.uk> wrote:

> Quite. And
>
>    print $i++, $i++;
>
> has DWIM forever (probably since perl 1).


Bad example. The operand evaluation order for the comma operator is not
undefined. It's documented that the arguments are evaluated from left to
right (allowing the comma can be used a "light" semicolon). A better example
would be

print $i-- + $i++;

The operand evaluation order of addition is not documented, so it could
return 5 or 7 for $i=3. But it always returns 5.

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