Bug #9983 Updated: Operator Precedence Clarification/Additions
| From: | hek at loudoun dot net | Date: | Thu, 07 Feb 2002 14:37:02 +0000 |
| Subject: | Bug #9983 Updated: Operator Precedence Clarification/Additions | ||
| References: | 1 | Groups: | php.dev php.doc |
| Request: | Send a blank email to php-dev+get-79527@lists.php.net to get a copy of this message | ||
ID: 9983
Updated by: hek@loudoun.net
-Reported By: yohgaki@dd.iij4u.or.jp
+Reported By: hek@loudoun.net
Status: Open
Bug Type: Documentation problem
Operating System: Linux/W2K
PHP Version: 4.0.4pl1
New Comment:
This is substantially the same as Bug#15368.
Previous Comments:
------------------------------------------------------------------------
[2001-06-27 03:37:24] yohgaki@dd.iij4u.or.jp
This is a suggestion for improving the manual.
(I don't mind at all if you close this :)
Reference is for PHP programmers, so I think precidence section is
better to include more operators.
For example, it does not matter if unary '+/-', array '[]', member
selecter '->', etc are treated by parser or internal function for
programmers. Programmers don't cares about it when they are programming
in some language, right?
Important thing for programmers is the precedence itself in some
expression.
How about add more description for precedence just like other books or
references for programming languages?
I feel precedence is not described fully in current manual and it's
worth the effort.
----Another Releated Suggestion----
I see confusion occasionally in mail lists for variables in string.
Since parser behaives differently when parsing variables in strings.
This may be one of the reason why '->','[]',unary'+/-' is not in
the
precedence section. They wouldn't work when they are in a string. (Some
of them work with newer PHP, not recommended(?) syntax, though)
How about describe these differences in the manual also?
------------------------------------------------------------------------
[2001-06-27 01:49:36] danbeck@php.net
Changing description to be more meaningful for someone who wants to
tackle this.
------------------------------------------------------------------------
[2001-03-26 05:10:50] yohgaki@dd.iij4u.or.jp
I read precedence list again. There is "." operator listed and has
higher precedence than "?:" operator. So PHP is working as expected. I
didn't see "." It was hard to see on my browser. Thanks.
Anyway, I have suggestion for the manual page, so I changed status to
open as "Documentation Problem".
I think the manual page better to have relevant language constructs in
the precedence list even if it is not a actually a operator in PHP.
(Such as "()", "{}", "::", "->", unary
"-","+". It seems these are not
a operator in PHP, since they are not listed. Not sure though.) Only
"()" is described in the section. All of them affects how expressions
are evaluated in script and I think precedence for these is important
as operator precedence because programmers want expressions are
evaluated as expected.
How about change the section title from "Operator Precedence" to
"Precedence"? Then documentation can include anything that can affects
expression and still have consistency with section title.
It also would be nice to have a little explaination for each operator
in the precedence list. Since it is ambigous if listed operator is
unary or binary. For example, unary "-" should have higher precedence
than binary "-". It would be obvious for most users, but it may be
usuful for someone.
------------------------------------------------------------------------
[2001-03-26 03:46:52] sniper@php.net
Please read this manual page:
http://www.php.net/manual/en/language.operators.precedence.php
--Jani
------------------------------------------------------------------------
[2001-03-26 00:17:05] yohgaki@dd.iij4u.or.jp
Following code, needs "()" to get expected value.
$bar = true;
$str = "TEST". ($bar ? 'true' : 'false') ."TEST";
Without "(" and ")", only "true" will be in $str.
(PHP4.0.4pl1/Apache DSO/Linux, PHP4.0.5RC1/Apache DSO/W2K Server)
If this is expected behavior in PHP, it would better to be described in
the Manual.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=9983&edit=1