RE: [PHP-DEV] Operator precedence is undefined?

2013-07-23 Thread Ford, Mike
-Original Message- From: yohg...@gmail.com [mailto:yohg...@gmail.com] On Behalf Of Yasuo Ohgaki Hi all, 2013/7/21 Sherif Ramadan theanomaly...@gmail.com The problem is I'm not sure where this type of information should be documented. It makes sense to put this on the

Re: [PHP-DEV] Operator precedence is undefined?

2013-07-20 Thread Sherif Ramadan
On Sat, Jul 20, 2013 at 1:33 AM, Sara Golemon poll...@php.net wrote: Your example -$a * $a isn't at all the same because -$a doesn't produce side-effects, only output. It doesn't have side effects. This is true. So I retract my argument there. I never said that the compiler might

Re: [PHP-DEV] Operator precedence is undefined?

2013-07-20 Thread Yasuo Ohgaki
Hi Sara, 2013/7/20 Sara Golemon poll...@php.net What's undefined isn't the relationship between preinc/postinc and add. What's undefined is the use of multiple preinc/postinc operators within a single expression (preincrements in particular). Our parser grammer, as it currently stands, does

Re: [PHP-DEV] Operator precedence is undefined?

2013-07-20 Thread Stas Malyshev
Hi! I cannot believe this is true now, but I ask list before I fix doc. I don't think there's something that needs to be fixed. Undefined means it depends on implementation and we do not want to commit to a specific behavior here because implementations may change. This is a fair warning

Re: [PHP-DEV] Operator precedence is undefined?

2013-07-20 Thread Stas Malyshev
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

Re: [PHP-DEV] Operator precedence is undefined?

2013-07-20 Thread Yasuo Ohgaki
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.

Re: [PHP-DEV] Operator precedence is undefined?

2013-07-20 Thread Sherif Ramadan
On Sat, Jul 20, 2013 at 3:37 AM, Stas Malyshev smalys...@sugarcrm.comwrote: Hi! I cannot believe this is true now, but I ask list before I fix doc. I don't think there's something that needs to be fixed. Undefined means it depends on implementation and we do not want to commit to a

Re: [PHP-DEV] Operator precedence is undefined?

2013-07-20 Thread Yasuo Ohgaki
Hi all, Explanation for undefined behaviors. === // If a side effect on a variable is unsequenced relative to another // side effect on the same variable, the behavior is undefined. $i = 1; $i = ++$i + $i++; // undefined behavior $i = $i++ + 1; // undefined behavior

Re: [PHP-DEV] Operator precedence is undefined?

2013-07-20 Thread Rasmus Lerdorf
On 07/20/2013 08:00 AM, Sherif Ramadan wrote: While this is very true it's also a matter of discretion, because the language doesn't clearly define a lot of things. In fact, one can argue that there is no language definition at all since PHP doesn't even have a spec. Though I'm trying to take

Re: [PHP-DEV] Operator precedence is undefined?

2013-07-20 Thread Stas Malyshev
Hi! I agree that we should not rush to commit changes in the midst of on-going discussion. However, I have to just add to this notion of undefined behavior that by your definition ALL of PHP is undefined behavior. Everything we do is an implementation detail. What This is certainly not true.

Re: [PHP-DEV] Operator precedence is undefined?

2013-07-20 Thread Sherif Ramadan
After some digging and a little more thought I find that removing this comment from the example in the docs at www.php.net/language.operators.precedence does indeed cause more harm than good. So I'm definitely wrong in saying that it should be removed. However, I would like to acknowledge the

Re: [PHP-DEV] Operator precedence is undefined?

2013-07-20 Thread Yasuo Ohgaki
Hi all, 2013/7/21 Sherif Ramadan theanomaly...@gmail.com The problem is I'm not sure where this type of information should be documented. It makes sense to put this on the increment/decrement operators page, but doesn't seem appropriate the operator precedence page. So to make sure we're all

[PHP-DEV] Operator precedence is undefined?

2013-07-19 Thread Yasuo Ohgaki
Hi all, Take a look at this bug report. https://bugs.php.net/bug.php?id=65087 He complains about documentation of ++/--. The doc says http://www.php.net/manual/en/language.operators.precedence.php --- // mixing ++ and + produces undefined behavior $a = 1; echo ++$a + $a++; // may

Re: [PHP-DEV] Operator precedence is undefined?

2013-07-19 Thread Sara Golemon
If run right now, it will always produce the same value (4), but it isn't *defined* to do so. What that means is that behavior is subject to change without notice, warning, or justification. This is a somewhat harsh way of saying Don't write expressions with ambiguous evaluations, that's clowny.

Re: [PHP-DEV] Operator precedence is undefined?

2013-07-19 Thread Yasuo Ohgaki
Hi Sara, 2013/7/20 Sara Golemon poll...@php.net I would ask that you don't fix the docs, as we want to continue to discourage users from engaging in unsafe behaviors. If precedence is implemented correctly, there should not be any ambiguity. If precedence is not implemented correctly, I

Re: [PHP-DEV] Operator precedence is undefined?

2013-07-19 Thread Sherif Ramadan
On Fri, Jul 19, 2013 at 8:55 PM, Yasuo Ohgaki yohg...@ohgaki.net wrote: Hi Sara, 2013/7/20 Sara Golemon poll...@php.net I would ask that you don't fix the docs, as we want to continue to discourage users from engaging in unsafe behaviors. If precedence is implemented correctly, there

Re: [PHP-DEV] Operator precedence is undefined?

2013-07-19 Thread Yasuo Ohgaki
Hi Sherif, Thank you for your info! 2013/7/20 Sherif Ramadan theanomaly...@gmail.com I don't see where there is a bug in the documentation, no. It is in doc's example code. -- // mixing ++ and + produces undefined behavior $a = 1; echo ++$a + $a++; // may print 4 or 5 --

Re: [PHP-DEV] Operator precedence is undefined?

2013-07-19 Thread Sherif Ramadan
On Fri, Jul 19, 2013 at 10:16 PM, Yasuo Ohgaki yohg...@ohgaki.net wrote: Hi Sherif, Thank you for your info! 2013/7/20 Sherif Ramadan theanomaly...@gmail.com I don't see where there is a bug in the documentation, no. It is in doc's example code. Then I would say that example is

Re: [PHP-DEV] Operator precedence is undefined?

2013-07-19 Thread Yasuo Ohgaki
Hi Sheif, 2013/7/20 Sherif Ramadan theanomaly...@gmail.com Then I would say that example is wrong, but people may find reason to disagree. I'm basing my contention purely off what I see in php-src and the documented behavior for those operators. To me I see no reason why this behavior would

Re: [PHP-DEV] Operator precedence is undefined?

2013-07-19 Thread Sherif Ramadan
On Fri, Jul 19, 2013 at 10:36 PM, Yasuo Ohgaki yohg...@ohgaki.net wrote: Hi Sheif, 2013/7/20 Sherif Ramadan theanomaly...@gmail.com Then I would say that example is wrong, but people may find reason to disagree. I'm basing my contention purely off what I see in php-src and the documented

Re: [PHP-DEV] Operator precedence is undefined?

2013-07-19 Thread Yasuo Ohgaki
Hi Sherif, I changed the example as follows. Thank you for your comment. [yohgaki@dev en]$ svn diff Index: language/operators.xml === --- language/operators.xml (リビジョン 330982) +++ language/operators.xml (作業コピー) @@ -225,15 +225,16 @@

Re: [PHP-DEV] Operator precedence is undefined?

2013-07-19 Thread Sara Golemon
On Fri, Jul 19, 2013 at 7:16 PM, Yasuo Ohgaki yohg...@ohgaki.net wrote: 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.

Re: [PHP-DEV] Operator precedence is undefined?

2013-07-19 Thread Sherif Ramadan
On Fri, Jul 19, 2013 at 11:56 PM, Sara Golemon poll...@php.net wrote: On Fri, Jul 19, 2013 at 7:16 PM, Yasuo Ohgaki yohg...@ohgaki.net wrote: 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.

Re: [PHP-DEV] Operator precedence is undefined?

2013-07-19 Thread Levi Morrison
On Fri, Jul 19, 2013 at 9:56 PM, Sara Golemon poll...@php.net wrote: On Fri, Jul 19, 2013 at 7:16 PM, Yasuo Ohgaki yohg...@ohgaki.net wrote: If there aren't comments, I'll rewrite the example. There were comments. I explicitly told you that that the behavior is defined as

Re: [PHP-DEV] Operator precedence is undefined?

2013-07-19 Thread Yasuo Ohgaki
Hi Sara, 2013/7/20 Sara Golemon poll...@php.net On Fri, Jul 19, 2013 at 7:16 PM, Yasuo Ohgaki yohg...@ohgaki.net wrote: 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

Re: [PHP-DEV] Operator precedence is undefined?

2013-07-19 Thread Sara Golemon
What's undefined isn't the relationship between preinc/postinc and add. What's undefined is the use of multiple preinc/postinc operators within a single expression (preincrements in particular). Our parser grammer, as it currently stands, does have a predictable order, but that is a side-effect

Re: [PHP-DEV] Operator precedence is undefined?

2013-07-19 Thread Sherif Ramadan
Sara, On Sat, Jul 20, 2013 at 12:44 AM, Sara Golemon poll...@php.net wrote: What's undefined isn't the relationship between preinc/postinc and add. What's undefined is the use of multiple preinc/postinc operators within a single expression I'm sorry but I can not find any evidence of how

Re: [PHP-DEV] Operator precedence is undefined?

2013-07-19 Thread Leigh
I'm disappointed $a+$a doesn't work as expected :( On 20 July 2013 06:08, Sherif Ramadan theanomaly...@gmail.com wrote: Sara, On Sat, Jul 20, 2013 at 12:44 AM, Sara Golemon poll...@php.net wrote: What's undefined isn't the relationship between preinc/postinc and add. What's

Re: [PHP-DEV] Operator precedence is undefined?

2013-07-19 Thread Sara Golemon
Your example -$a * $a isn't at all the same because -$a doesn't produce side-effects, only output. I never said that the compiler might magically produce differing results for the same input. I said that the language's definition does not declare a defined behavior for such expressions with

Re: [PHP-DEV] Operator precedence is undefined?

2013-07-19 Thread Adam Harvey
(Piggy-backing on Sara's e-mail, although this is more a response to Sherif and Yasuo.) On 19 July 2013 22:33, Sara Golemon poll...@php.net wrote: I never said that the compiler might magically produce differing results for the same input. I said that the language's definition does not declare