#17180 [Com]: Operator Precedence

From: Date: Mon, 20 Jan 2003 18:06:56 +0000
Subject: #17180 [Com]: Operator Precedence
References: 1  Groups: php.doc 
Request: Send a blank email to phpdoc+get-969351111@lists.php.net to get a copy of this message
ID: 17180 Comment by: m.ford@lmu.ac.uk Reported By: sitnikov@infonet.ee Status: Closed Bug Type: Documentation problem PHP Version: 4.2.0 New Comment: There seems to be a more general principle at work here -- see, for example, related bug report 17386 (http://bugs.php.net/bug.php?id=17386). Would it be true to say something like: when an assignment operator occurs in a position where the usual rules of precedence would produce a parse error, the precedence of the assignment is artificially increased to allow the expression to parse; this usually gives the intended result. Cheers! Mike Previous Comments: ------------------------------------------------------------------------ [2003-01-18 16:14:46] philip@php.net This has now been documented: http://cvs.php.net/cvs.php/phpdoc/en/language/operators.xml Thanks for the report :) ------------------------------------------------------------------------ [2002-05-16 13:27:03] derick@php.net Marking this as a doc problem. ------------------------------------------------------------------------ [2002-05-14 13:46:58] phpclub@digiways.com Actually this is a bug, since in PHP manual it's clearly stated that ! operator has a priority over = operator. > It makes no sense to assign anything to NOT(a variable), > so PHP takes care of that by > changing the precedence a little in this case. In other words - if user makes a mistake and writes illegal code, PHP takes care about that and makes this code work (but in a way different from what developer has expected). Also if you consider any other programming languages, if you write a code which should not compile by language specifications (like the above code in PHP), no compiler will try to "take care" of that. If you insist on that "care", then you definetely have to reflect that in the manual, otherwise it's nothing but a bug. ------------------------------------------------------------------------ [2002-05-13 18:30:31] sitnikov@infonet.ee This behaviour is capable to confuse the developer and if this is "features" it must be documented in manual. ------------------------------------------------------------------------ [2002-05-13 18:20:14] manuzhai@php.net Well, but it's stupid to do something like that. It makes no sense to assign anything to NOT(a variable), so PHP takes care of that by changing the precedence a little in this case. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/17180 -- Edit this bug report at http://bugs.php.net/?id=17180&edit=1

« previous php.doc (#969351111) next »