Re: Add spaceship assignment operator
| From: | Nikita Popov | Date: | Thu, 24 Mar 2016 19:16:58 +0000 |
| Subject: | Re: Add spaceship assignment operator | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-91922@lists.php.net to get a copy of this message | ||
On Thu, Mar 24, 2016 at 8:05 PM, Sara Golemon <pollita@php.net> wrote:
> On Thu, Mar 24, 2016 at 11:50 AM, Colin O'Dell <colinodell@gmail.com>
> wrote:
> > Would your proposal also allow !==== to work?
> >
> I think you means !===, which is "not-identical assignment" (!== =)
>
> !==== is just *CRAZY TALK*
>
We shouldn't dismiss such things out of hand, Sara. Consider the following
argument:
There is a binary !== operator. The compound assignment version of it is
!===. But that again is a binary operator! So there should be a !====
compound assignment operator as well. By induction over the natural numbers
it follows that !== followed by an arbitrary number of =s should be a valid
compound assignment operator.
However, when considering the expansion, we see:
$a !==== $b;
// same as
$a = $a !=== $b;
// same as
$a = $a = $a !== $b;
It is now evident that $a !==== $b (or any additional number of =s) has the
same meaning as $a !=== $b. A difference could only arise if the left-hand
side is an object implementing __set or ArrayAccess, in which case !====
would cause an additional call to __set / offsetSet.
Given that !==== and !=== would be, apart from the edge-case of overloaded
objects, identical, I must concur with your original judgement that only
supporting !=== is sufficient.
Thanks,
Nikita