Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Opera tor

[email protected]
Newsgroups php.internals
Message-ID <[email protected]>
From: Andrey Andreev
Sent: ‎Monday‎, ‎September‎ ‎8‎, ‎2014 ‎5‎:‎16‎ ‎PM
To: Andrea Faulds
Cc: Adam Harvey, Christoph Becker, PHP internals





>On Tue, Sep 9, 2014 at 3:07 AM, Andrea Faulds <[email protected]> wrote:
>>
>> On 8 Sep 2014, at 23:58, Adam Harvey <[email protected]> wrote:
>>
>>> +1 on ?? — there's precedent for it, and it means we don't have to
>>> explain why the shorthand form of an operator behaves differently to
>>> the long form, which is just going to confuse users.
>>
>> FWIW, it already behaves differently:
>>
>>     oa-res-27-90:~ ajf$ php -r 'function foo() { echo "foo\n"; return true; } $x = foo() ?: false;'
>>     foo
>>     oa-res-27-90:~ ajf$ php -r 'function foo() { echo "foo\n"; return true; } $x = foo() ? foo() : false;'
>>     foo
>>     foo
>
>That's arguable ... I'd say that ($x = foo()) ? $x : false; is the
>logical equivalent of your first example.
>
>Cheers,
>Andrey.



I agree and think we should go with a different operator as others suggested. If not ?? than we could use ?=  like $foo ?= “default string”.


-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.