Re: com php-src: Array addition is not commutative: Zend/zend_vm_def.h Zend/zend_vm_execute.h Zend/zend_vm_opcodes.c
| From: | Nikita Popov | Date: | Fri, 15 Dec 2017 15:09:41 +0000 |
| Subject: | Re: com php-src: Array addition is not commutative: Zend/zend_vm_def.h Zend/zend_vm_execute.h Zend/zend_vm_opcodes.c | ||
| References: | 1 2 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-100599@lists.php.net to get a copy of this message | ||
On Fri, Dec 15, 2017 at 4:04 PM, Nikita Popov <nikita.ppv@gmail.com> wrote:
> On Fri, Dec 15, 2017 at 12:40 PM, Dmitry Stogov <dmitry@php.net> wrote:
>
>> Commit: 66a604171cc676ebc8cb717437f6b9cd589d3d24
>> Author: Dmitry Stogov <dmitry@zend.com> Fri, 15 Dec 2017
>> 14:40:19 +0300
>> Parents: 588f1df7a24867a43e9574b57957e6fca2518c17
>> Branches: master
>>
>> Link:
>> http://git.php.net/?p=php-src.git;a=commitdiff;h=66a6041
>> 71cc676ebc8cb717437f6b9cd589d3d24
>>
>> Log:
>> Array addition is not commutative
>>
>
> If operator overloading for objects is used, then mul is also not
> necessarily commutative. E.g. multiplication on two Matrix objects is not
> commutative.
>
> Nikita
>
In general, I think doing this is only really safe for IS_IDENTICAL and
IS_NOT_IDENTICAL. For everything else there may be issues due to operator
overloading or comparison overloading. Though probably IS_EQUAL and
IS_NOT_IDENTICAL are fine as well, non-commutative equality would be very
weird.
Nikita