note 76174 added to language.operators.comparison
| From: | rofthorax at gmail dot com | Date: | Tue, 03 Jul 2007 21:24:38 +0000 |
| Subject: | note 76174 added to language.operators.comparison | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-128203@lists.php.net to get a copy of this message | ||
The truth table according to self-deceiving PHP language developers:
$a = "1hwio123";
$b = "1hwio123";
$a == $b is true
$a = "12345";
$a == $b is false;
$b = 12345;
$a == $b is false;
$b = 12345;
$a == $b is true;
If PHP is an interpreter, surely it can make sound judgement about operands before comparing them,
like if both operands contain numbers and no letters, reduce both operands to integer types before
comparing. But if at least one operand contains letters, type cast both operands to strings..
Why is this not logical? The intepreter has the ability where a compiler does not.. Is this decision
made in the interest of making PHP code compileable? What can't you just place a flag in the
compiler to allow developers to treat comparisons as special cases that need to be interpretted at
runtime, vesus solving the problem at compile time.. Why should those of us using interpreters be
punished by the limitations of what can and can't be compiled to something that supposedly will
run faster.. What is 15% speed savings to having perceptively correct code?
----
Server IP: 208.69.120.35
Probable Submitter: 69.241.171.211
----
Manual Page -- http://www.php.net/manual/en/language.operators.comparison.php
Edit -- https://master.php.net/note/edit/76174
Del: integrated -- https://master.php.net/note/delete/76174/integrated
Del: useless -- https://master.php.net/note/delete/76174/useless
Del: bad code -- https://master.php.net/note/delete/76174/bad+code
Del: spam -- https://master.php.net/note/delete/76174/spam
Del: non-english -- https://master.php.net/note/delete/76174/non-english
Del: in docs -- https://master.php.net/note/delete/76174/in+docs
Del: other reasons-- https://master.php.net/note/delete/76174
Reject -- https://master.php.net/note/reject/76174
Search -- https://master.php.net/manage/user-notes.php