[VOTE][RFC] Null Coalesce Operator

php.internals

Andrew Faulds

11 years ago
Good evening, I’ve put the Null Coalesce Operator RFC to a vote: https://wiki.php.net/rfc/isset_ternary#vote It is a 2/3 majority vote and ends in a week’s time on 2014-09-27. For anyone wondering, I’ve decided not to include ??= because we don’t have an assignment operator for ?: either, nor does C# have one, it may be a pain to implement, and I’m not sure we need it. Thanks!
-- Andrea Faulds http://ajf.me/

Patrick Schaaf

11 years ago
Am 20.09.2014 01:35 schrieb "Andrea Faulds" <ajf@ajf.me>:
> > https://wiki.php.net/rfc/isset_ternary#vote
Hi, got a question after being bitten my the issue yesterday in the context of the "@yadda ?: 'default'" form yesterday: What about yadda that results, at the moment, in fatal errors?? Things like static::$missingproperty, $this->missingmethod(), and other stuff? Will the ?? operator A) make these non-fatal B) silently fatal (like now when @ is used) C) loudly fatal (like when no @ is used) D) depends on what fatal it is? To me the most annoying case here, not only in relation to ?? of course, is the different behaviour of $this->missingproperty and someclass::$missingproperty, with the latter being fatal, but easily provocable by a call to unset(someclass::$missingproperty earlier in the code. best regards Patrick

Nikita Popov

11 years ago
On Sat, Sep 20, 2014 at 9:40 AM, Patrick Schaaf <php@bof.de> wrote:
> Am 20.09.2014 01:35 schrieb "Andrea Faulds" <ajf@ajf.me>: > > > > https://wiki.php.net/rfc/isset_ternary#vote > > Hi, > > got a question after being bitten my the issue yesterday in the context of > the "@yadda ?: 'default'" form yesterday: > > What about yadda that results, at the moment, in fatal errors?? Things like > static::$missingproperty, $this->missingmethod(), and other stuff? > > Will the ?? operator > A) make these non-fatal > B) silently fatal (like now when @ is used) > C) loudly fatal (like when no @ is used) > D) depends on what fatal it is? >
$this->missingmethod() ?? null will continue to be (loudly) fatal (or recoverable fatal, once a recent RFC is merged). static::$missingproperty ?? null will not throw an error, as it is subject to isset().
> To me the most annoying case here, not only in relation to ?? of course, is > the different behaviour of $this->missingproperty and > someclass::$missingproperty, with the latter being fatal, but easily > provocable by a call to unset(someclass::$missingproperty earlier in the > code. >
It's not possible to unset a static property, see http://3v4l.org/PkD36. Which is probably also why accessing an undefined static property is fatal as well ;) Nikita

Derick Rethans

11 years ago
On Sat, 20 Sep 2014, Patrick Schaaf wrote:
> Am 20.09.2014 01:35 schrieb "Andrea Faulds" <ajf@ajf.me>: > > > > https://wiki.php.net/rfc/isset_ternary#vote > > Hi, > > got a question after being bitten my the issue yesterday in the context of > the "@yadda ?: 'default'" form yesterday: > > What about yadda that results, at the moment, in fatal errors?? Things like > static::$missingproperty, $this->missingmethod(), and other stuff? > > Will the ?? operator > A) make these non-fatal > B) silently fatal (like now when @ is used)
It should be this one to be consistent. @ is shit, but sadly can not be avoided in all situations. cheers, Derick

Dmitry Stogov

11 years ago
looks like Perl magic :( -1 Dmitry. On Mon, Sep 22, 2014 at 3:31 PM, Derick Rethans <derick@php.net> wrote:

Pascal MARTIN

11 years ago
On 20/09/2014 01:34, Andrea Faulds wrote:
> > I’ve put the Null Coalesce Operator RFC to a vote: > > https://wiki.php.net/rfc/isset_ternary#vote > > It is a 2/3 majority vote and ends in a week’s time on 2014-09-27. >
Hi, We've discussed this RFC with other members of AFUP (French UG), and we've written quite a few mails about the ?? operator itself and a few other ideas. To summarize, we pretty much all agree that having to use isset() in order to avoid a notice is often cumbersome, and that a proposal that would allow us to write shorter code is nice. Using a new operator also feels better than changing the behavior of ?: and the ?? operator should not be hard to remember and understand. A new ??= operator might be useful, but not having it right away is OK: it'll still be possible to add it in the future, if enough people using ?? feel that ??= could help too. So, basically, +1 ;-)
-- Pascal MARTIN http://blog.pascal-martin.fr/ @pascal_martin

Andrew Faulds

11 years ago
> On 20 Sep 2014, at 00:34, Andrea Faulds <ajf@ajf.me> wrote: > > I’ve put the Null Coalesce Operator RFC to a vote: > > https://wiki.php.net/rfc/isset_ternary#vote > > It is a 2/3 majority vote and ends in a week’s time on 2014-09-27.
By 31 votes to 3, the RFC has passed and voting has now closed. If there are no objections, I'll merge the patch sometime soon and work on a specification patch.
-- Andrea Faulds http://ajf.me/