Re: Revisiting RFC: Engine Warnings -- Undefined array index
| From: | Rowan Tommins | Date: | Tue, 13 Dec 2022 16:59:47 +0000 |
| Subject: | Re: Revisiting RFC: Engine Warnings -- Undefined array index | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-119132@lists.php.net to get a copy of this message | ||
On 13/12/2022 16:08, Dan Liebner wrote:
Can I also just point out that by current definitions the "null coalescing operator" isn't properly named, it should be the "undefined/null coalescing operator". The only reason it is able to get away with not raising an error for undefined variables is that it's described as "syntactic sugar" for isset(), which is itself the exception to the rule for not raising undefined errors.Other languages, such as JavaScript, would raise an error for an expression such asCan you expand a bit on how you think distinguishing "undefined" from "null" would help? Let's keep the focus on possible solutions, not just arguing in circles. It's always been a source of confusion to me that JS has both, and the syntax for working them seems far from elegant (unless things have improved, and you no longer need to use typeof to detect undefined?); but maybe I'm looking at it wrong. Regards, -- Rowan Tommins [IMSoP]undefinedvar ?? 0. And JavaScript conveniently offers the undefined primitive for precisely handling attempted accesses of undefined keys, while retaining the brevity and convenience of a truthy/falsyobj.keycheck.