fail-fast object destructuring (don't add more slop to sloppy mode)

Brendan Eich brendan at
Wed Jan 2 07:57:33 PST 2013

Herby Vojčík wrote:
> I advised adding Null Pattern Object into language in the 
> aforementioned thread; and use foo? as `foo == null ? 
> NullPatternObject : foo`.
> So you can do `r = o?.p.q`; and it does not fail.

Separate topic, and we considered it as an alternative to CoffeeScript's 
non-compositional rewrite-based semantics at the September TC39 meeting, 
but did not proceed. Thanks for the reminder, I will update

> With such construct you could do
>   let {p: {q: r}} = deep_o?; 

This does not address the problem for destructuring. It's true a Nil 
object (as Brandon Benvie prototyped: can be deeply 
destructured. But there is no refutable match future. We need an 
exception on missing property, not a magic get/set-sink object.

The suffix-? syntax in expressions is problematic in combination with 
missing semicolons. You get another case where programmers expect ASI 
but there's no error to correct:

   x = y?

where z is label and w is a statement that can syntactically (if not 
sensibly) be labeled.


More information about the es-discuss mailing list