Specifying the Existential Operator using Abrupt Completion

Allen Wirfs-Brock allen at wirfs-brock.com
Wed May 21 09:40:12 PDT 2014

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

> On 21 May 2014 14:33, Claude Pache <claude.pache at 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.


More information about the es-discuss mailing list