Hi Stas,

2013/7/20 Stas Malyshev <smalys...@sugarcrm.com>

> Hi!
>
> >> If there aren't comments, I'll rewrite the example.
> >>
> >>
> >> There were comments.  I explicitly told you that that the behavior is
> > defined as undefined.  You CHOSE to ignore that comment.  You CHOSE to
> > break the documentation.
>
> Besides that, asking for comments and committing the same day is not
> really conductive to a good discussion. Even if nobody objected - which
> explicitly wasn't the case - there's nothing that prevented waiting for
> a couple of days just to be sure. Please, let us not to be too hasty.
>

Fair discussion. I'll revert the commit for now.
Keeping room for better compilers is good, too.

Anyway, the restriction is needed to be documented.
How about this explanation?

<?php
$a = 3 * 3 % 5; // (3 * 3) % 5 = 4
// ternary operator associativity differs from C/C++
$a = true ? 0 : true ? 1 : 2; // (true ? 0 : true) ? 1 : 2 = 2

$a = 1;
$b = 2;
$a = $b += 3; // $a = ($b += 3) -> $a = 5, $b = 5

// mixing ++/-- and arithmetic operators may produce
// unexpected results, since the evaluation order depends
// on compiler implementation.
$a = 1;
echo ++$a + $a++; // not supported
?>

If expression like "echo ++$a + $a++" is not supported for future
compilers,  PHP is better to raise E_NOTICE if it is easy and fast.

Regards,

--
Yasuo Ohgaki
yohg...@ohgaki.net

Reply via email to