On May 21, 2014, at 5:56 AM, Andreas Rossberg wrote:

> On 21 May 2014 14:33, Claude Pache <claude.pa...@gmail.com> wrote:
>> 
>> I have thought about the right semantics (and the issues) of the existential 
>> operator.
>> 
>>    user.getPlan?().value?.score;
>> 
>> The intended semantics of `?` is that, whenever its LHS evaluates to `null` 
>> or `undefined`,
>> the evaluation of the whole expression (or subexpression) is interrupted and 
>> return immediately `undefined`.
>> In other word, it may be seen as an abrupt completion, as demonstrated by 
>> the following expansion:
>> 
>>    (do {
>>        let result = user           // user
>>        result = result.getPlan // _.getPlan
>>        if (result == null)         // _?
>>            break                   // abrupt completion
> 
> Drive-by comment: This would break the switch or loop statement
> surrounding the do-expression (or be an error if there isn't any). You
> need to wrap the statements into a labelled block and break that.

Well, completion records are just a specification device and if we need a new 
[[type]] of abrupt completion to simplify specifying some semantics we 
certainly could add it.

Allen
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to