Re: Add spaceship assignment operator

From: Date: Thu, 24 Mar 2016 18:33:39 +0000
Subject: Re: Add spaceship assignment operator
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-91915@lists.php.net to get a copy of this message
Hi Nikita, On Thu, Mar 24, 2016 at 11:50 AM, Nikita Popov <nikita.ppv@gmail.com> wrote: > Hi internals! > > For consistency, we should add a spaceship assignment operator: > > $a <=>= $b; > // same as > $a = ($a <=> $b); > I'm not sure I see a use case for this, when do you compare 2 values and replace one of those values with the result of the comparison? I've literally never done that. > > Additionally, we should add an is-identical assignment operator: > > $a ==== $b; > // same as > $a = ($a === $b); > Again, why would you do this? How often are you replacing the contents of a variable with the results of comparing it with something else? $c = $a === $b; $c = $a <=> $b; That seems to be far more common if assigning the results to a variable at all (which is itself not that common for comparisons in my experience). > > Thank you for taking this proposal under consideration. > > Regards, > Nikita > Thanks for bringing this up, but I don't see the consistency argument, and I don't feel like its normal use cases at all.

« previous php.internals (#91915) next »