Req #71090 [Opn->Sus]: Comparison operators should be transitive
| From: | stas@php.net | Date: | Sat, 05 Aug 2017 04:45:22 +0000 |
| Subject: | Req #71090 [Opn->Sus]: Comparison operators should be transitive | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-210506@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=71090&edit=1
ID: 71090
Updated by: stas@php.net
Reported by: reallfqq-php at yahoo dot fr
Summary: Comparison operators should be transitive
-Status: Open
+Status: Suspended
Type: Feature/Change Request
Package: Scripting Engine problem
PHP Version: 7.0.0
Block user comment: N
Private report: N
New Comment:
Thank you for your interest in PHP and for submitting a feature request. Please be aware that due to
the magnitude of change this request requires, it would be necessary to discuss it on PHP Internals
list (internals@lists.php.net) as an RFC. Please read the guide about creating RFCs here:
https://wiki.php.net/rfc/howto
If you haven't had experience with writing RFCs before, it is advised to seek guidance on the
Internals list (http://php.net/mailing-lists.php) and/or solicit help from one of the experienced
developers.
Please to not consider this comment as a negative view on the merits of your proposal - every
proposal which requires changes of certain magnitude, even the very successful and widely supported
ones, must be done through the RFC process. This helps make the process predictable, transparent and
accessible to all developers.
Previous Comments:
------------------------------------------------------------------------
[2016-08-15 10:04:55] cmb@php.net
Related To: Bug #72835
------------------------------------------------------------------------
[2016-07-29 22:16:07] reallfqq-php at yahoo dot fr
I take good note that, in PHP world, operator intransitiveness is not a bug, but a feature, and that
correct operators graph is a 'feature request', much like a cherry on the cake.
No wonder PHP fuses keep melting...
The problem we are talking about is language design and grammar, not comparing apples and oranges.
Do not mix programmings mistake and design flaw/broken core grammar rule, since criticity of each
case is several universes apart.
Every programming language should respect some basic rules. I am amazed I even needed to fill this
bug report, and even more amazed I feel like I need to push on it and explain those things to
people... crafting a programming language!
It seems like you do not know the essence of your field and noobs are teaching *alleged* experts.
You answer is gold: totally irrelevant. You should step away from creating programming languages, or
attend 101. For the greater good.
Anyway: there are none so deaf as those who will not listen.
------------------------------------------------------------------------
[2016-07-29 13:08:07] cmb@php.net
For reference: <https://3v4l.org/S9NjT> and
<https://3v4l.org/84MV5>.
> The bug report example actual shows a near-real-world use-case
> where the sort function is unable to do its job. That is more
> spectacular.
So comparing apples to oranges is a near-real-world use-case?
Anyhow, we can't simply change the historic behavior, because
somebody claims it would be bug (despite the behavior is exactly
documented), so I'm changing this ticket to feature request. Most
likely an RFC would be required, to cater to the supposedly
significant BC break.
------------------------------------------------------------------------
[2015-12-11 20:20:17] danack@php.net
Just to note, this is the actual output.
PHP Notice: Object of class stdClass could not be converted to int in ./sorting.php on line 11
PHP Stack trace:
Notice: Object of class stdClass could not be converted to int in ./sorting.php on line 11
PHP 1. {main}() ./sorting.php:0
Call Stack:
PHP 2. is_sorted() ./sorting.php:23
0.0002 226856 1. {main}() ./sorting.php:0
0.0003 228360 2. is_sorted() ./sorting.php:23
bool(false)
Almost as if the code is trying to tell you that you're doing something bogus...
------------------------------------------------------------------------
[2015-12-11 19:39:56] reallfqq-php at yahoo dot fr
Short answer :
*Wrong*. Try the following code:
<?php
$a = 15;
$b = array();
$c = (object)array();
var_dump($a < $b);
var_dump($b < $c);
var_dump($c < $a);
?>
Result:
bool(true)
bool(true)
bool(true)
----------
Long answer:
Please do not oversee the problem and oversimplify it.
I am talking about operators, not constants. The problem is not INF at all.
Have you checked the linked webpage?
The first example show non-transitivity of some operators:
php -r 'var_dump(TRUE == "a"); var_dump("a" == 0); var_dump(TRUE ==
0);'
Expected :
bool(true)
bool(true)
bool(true)
Actual:
bool(true)
bool(true)
bool(false)
Then, and I think that is the biggest concern, there is circular references in the operators chain,
demonstrated in the bug report.
The bug report example actual shows a near-real-world use-case where the sort function is unable to
do its job. That is more spectacular.
------------------------------------------------------------------------
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
https://bugs.php.net/bug.php?id=71090
--
Edit this bug report at https://bugs.php.net/bug.php?id=71090&edit=1