Re: [RFC] Implicit isset() in Shorthand Ternary Operator
| From: | Chris Wright | Date: | Thu, 18 Sep 2014 16:08:09 +0000 |
| Subject: | Re: [RFC] Implicit isset() in Shorthand Ternary Operator | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-77311@lists.php.net to get a copy of this message | ||
On 18 September 2014 14:34, Johannes Schlüter <johannes@schlueters.de> wrote:
> On Thu, 2014-09-18 at 12:41 +0100, Andrea Faulds wrote:
>> We could use a function *syntax*, though, but I don’t like this idea.
>> coalesce() and ifsetor() are both ugly to me, and it’s not super
>> obvious what they do:
>>
>> var_dump(coalesce($_GET[‘foobar’], 3));
>>
>> vs.
>>
>> var_dump($_GET[‘foobar’] ?? 3);
>>
>> ?? also has the advantage of being shorter.
>>
> If you don't now what ?? does it's far from obvious. coalesce is a term
> that can be put into google and will deliver results.
On the flip side, coalesce() etc would introduce another keyword,
which would be a BC break, unless we also manage to get
keywords-as-identifiers working and accepted for the same release.
I wouldn't mind betting there are quite a few applications out there
with a function/method called coalesce() defined... I know there's at
least one, because I work on it regularly, and github has over 100,000
hits for it (the vast majority of these are in SQL strings but I still
found 4 PHP functions/methods on the first 3 pages):
https://github.com/search?q=coalesce+language%3Aphp&type=Code