Paul Johnson wrote:
On Fri, Oct 20, 2006 at 12:23:57PM +0100, Rob Dixon wrote:
Paul Johnson wrote:
On Fri, Oct 20, 2006 at 10:56:09AM +0200, Dr.Ruud wrote:
Norbert Preining schreef:
Dr.Ruud:
$ perl -wle '
$a = 3;
$b = 0 + (++$a) + ($a++);
print "b=$b\n";
'
b=8
:)
Nup, this is not the solution:
Solution?
It showed that there is a bug. I already reported it.
And I already replied ENOTABUG as promised ;-)
It's clear what the language should be doing in this situation and it
isn't doing it, so it's broken. It's only not a bug in the sense that
it's documented to be broken.
I suppose this depends on whether you fall into the C camp or the Java
camp on this one. (Substitute your favourite language that either does
or does not define an order of evaluation.)
But it's not a problem with the order of evaluation Paul. Whether you think
$b = ++$a + $a++
means
$b = ++$a;
$b += $a++;
or
$b = $a++;
$b += ++$a;
the answer comes out the same, and different from what Perl makes of it. Perl is
turning it into
$b = (++$a, $a++, $a + $a)
So an error has been optimised in, and what is worse is that it does it without
a squeak of a warning; this in a language that will whine if you use an array
slice when it thinks you don't mean one.
Rob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>