Existential Operator / Null Propagation Operator

Andreas Rossberg rossberg at google.com
Tue Jun 2 17:06:27 UTC 2015

On 2 June 2015 at 18:57, Brendan Eich <brendan at mozilla.org> wrote:

> Sander Deryckere wrote:
>> 2015-06-02 17:49 GMT+02:00 Brendan Eich <brendan at mozilla.org <mailto:
>> brendan at mozilla.org>>:
>>     Sander Deryckere wrote:
>>         For the prefix operator, it's unclear to me how you would do
>>         the following: Say you know `obj` is non-null, you want to
>>         test if it has a key `k1`, but if `k1` exists, you know it
>>         will also have a key `k2` a level deeper. With the suffix
>>         operator, this would be `obj[k1]?[k2]`, but with the prefix
>>         operator, it could be `obj?[k1][k2]`
>>     You circled back to the incompatible syntax, `?[`, but the prefix
>>     idea would have `?obj[k1][k2]`. The `?` goes in front at the start
>>     of an operand, and is thus unambiguous with respect to the ternary
>>     operator.
>> The question is not about the existence of `obj`, but if `obj` has a key
>> `k1`. AFAICS, `?obj[k1][k2]` would test the existence of `obj`, which I
>> don't need in this example. To test the existence of a key inside `obj`, a
>> prefix operator should come somewhere before the key.
> You might hope for that, but as we both noted, `?[` is not going to fly.
> Don't break the (minified) Web.
> The prefix idea generalizes:
> ?obj[key]
> obj[?key]
> obj[key1][?key2]

Hm, what's the meaning of



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150602/f1aea1bd/attachment-0001.html>

More information about the es-discuss mailing list