fail-fast object destructuring (don't add more slop to sloppy mode)
brendan at mozilla.com
Thu Jan 3 17:50:28 PST 2013
Nathan Wall wrote:
> Brendan Eich wrote:
>> Herby Vojčík wrote:
>>> Now I am confused.
>>> For (p.q?).r to be same as p.q?.r, (p.q?) must return reified Nil, not
>>> undefined. I was at the impression you say "Nil at the background, but
>>> whenever it becomes observable, it should be changed to undefined".
>>> That means p.q? returns undefined, and (p.q?).r fails.
>> Obviously I don't want these different parenthesizations to fail. I
>> believe we can spec the semantics such that InternalNil, just like
>> ES1-6's Reference type, is not observable.
> What happens in more complicated expressions?
> let foo, bar = (foo = p.q?).r;
That depends, among other things, on whether ?. is one new lexeme or two!
IOW, you shouldn't assume that ?. in the expression language means ?
(suffix-?) is in the expression language.
Of course, we could do all three of nil, ? and ?. as Herby wants. That
is ES7 for sure and it ties things up in a bow. But is nil really worth
it, never mind suffix-? in expressions?
> It would be strange to me if `foo === undefined&& bar === undefined`. Herby's proposal that `foo === nil&& bar === nil` makes more sense.
Given nil and the ability to write suffix-? inside parens, and dot
after, I agree.
Not sold on tying ?. to -? and nil yet, tho!
More information about the es-discuss