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

Brendan Eich brendan at mozilla.com
Wed Jan 2 12:07:22 PST 2013


Kevin Smith wrote:
>
>     Interpreted this way, any additional irrefutable markers in a
>     subtree under a refutable identifier become redundant, correct?
>
>
> Er, meant this:
>
> Interpreted this way, any additional irrefutable markers in a subtree 
> under an _irrefutable_ identifier become redundant, correct?

For the proposal to use Nil for the expression semantics, yes.

You're right, this implies destructuring binding forms behave in a way 
that I flagged as possibly not wanted:

   let {p?: {q: r}} = o;

would bind r to undefined for any o that doesn't have a p or that does 
but o.p doesn't have a q.

On second look this is not as bad as I thought. It would be bad if r 
were not bound (so an outer r could become visible) depending on o's 
dynamics. That seems right out!

/be
>
>
>         r = o?.p?.q    { p?: { q?: r } } = o
>
>     Using Nil, the "q" in all cases is "present" (evaluating to Nil),
>     so the "?" in "q?" has no effect.  Is that right?
>
>


More information about the es-discuss mailing list