Re: [RFC] Implicit isset() in Shorthand Ternary Operator

From: Date: Mon, 08 Sep 2014 08:47:45 +0000
Subject: Re: [RFC] Implicit isset() in Shorthand Ternary Operator
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-77101@lists.php.net to get a copy of this message
On Mon, Sep 8, 2014 at 4:06 AM, Michael Wallner <mike@php.net> wrote: > On 07/09/14 14:25, Andrea Faulds wrote: > > > > > There’s actually a quite serious issue just now, which is that it > > evaluates the first operand twice if it’s not empty. This is because > > $a ?: $b is expanded to empty($a) ? $b : $a, such that if you did > > something which mutates state in there, it’d happen twice. This is > > obviously not good, and I’m going to figure out how to fix this.. > > > > This could very well be the reason why it is like it is today. > > I agree. The more I think about, the more this seems weird. What if I explicitly want to use ternary to check isset() and not empty?

« previous php.internals (#77101) next »