#41228 [Opn->Csd]: Side-effects for logical operators
| From: | colder@php.net | Date: | Mon, 30 Apr 2007 17:02:57 +0000 |
| Subject: | #41228 [Opn->Csd]: Side-effects for logical operators | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969376212@lists.php.net to get a copy of this message | ||
ID: 41228
Updated by: colder@php.net
Reported By: terminatorul at gmail dot com
-Status: Open
+Status: Closed
Bug Type: Documentation problem
PHP Version: Irrelevant
-Assigned To:
+Assigned To: colder
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation
better.
Previous Comments:
------------------------------------------------------------------------
[2007-04-30 12:03:44] arpad@php.net
My point was that the term "short-circuit" is already mentioned twice
on the page, if you didn't know what it meant in this context then a
google search for "short-circuit operator" would yield a page full of
relevant results.
Of course it could be spelled out in the text, but even if I was in
favour of doing so, I don't have phpdoc karma. That's why I just stated
my opinion and left the bug open.
------------------------------------------------------------------------
[2007-04-30 11:50:08] terminatorul at gmail dot com
My point exactly.
A programing language may or may not guarantee side-effects from
evaluation of operands to logical operators. Or at least would say
that it is undefined if the side-effect occurs.
The proffesional C++ programmer will find it normal for the language to
shortcut the expression, while a beginner will not understand what's
wrong with his/her code.
------------------------------------------------------------------------
[2007-04-30 11:44:35] rquadling@php.net
Good ole MS! http://support.microsoft.com/kb/817250
------------------------------------------------------------------------
[2007-04-30 11:42:27] rquadling@php.net
Two opposing thoughts.
Delphi -
http://info.borland.com/techpubs/delphi/delphi5/oplg/syntlmnt.html#10548
In Delphi, shortcut/short-circuit is optional, though as standard it is
enabled.
VB -
http://www.informit.com/guides/content.asp?g=dotnet&seqNum=480&rl=1
Seemingly VB does NOT have a short circuit.
Who do you believe. For the seasoned programmer, this is perfectly
obvious. But if you're upgrading your skill set from, say, VB, then this
REALLY odd behaviour is completely new. And what debugging would you
provide?
This should be documented and probably in several places as there are
many references to boolean logic throughout the manual.
It is the LACK of documentation on this standard feature within PHP
that is the issue.
------------------------------------------------------------------------
[2007-04-30 10:08:31] arpad@php.net
This isn't a side-effect, but an intrinsic property of these operators.
As two out of the four user notes on the page mention, the first dating
back to 1999, these operators short-circuit.
Perhaps this could be explained in the text to make it clearer for
people new to programming, but I don't think there's any great need;
I assume most people can look up terms they're not familiar with.
------------------------------------------------------------------------
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/41228
--
Edit this bug report at http://bugs.php.net/?id=41228&edit=1