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

Brendan Eich brendan at mozilla.com
Wed Jan 2 09:02:41 PST 2013


Herby Vojčík wrote:
>> This does not address the problem for destructuring. It's true a Nil
>> object (as Brandon Benvie prototyped:
>> https://github.com/Benvie/nil/blob/master/nil.js) can be deeply
>> destructured.
>
> That is what I meant.

Thought so ;-).

>> But there is no refutable match future. We need an
>
> I don't understand. :-/

We want a way to match with patterns like so:

   match (expr) {
     case {must, may?} => ...
     case {always} => ...
   }

In other words, the ? must go in the LHS pattern language, not on the 
RHS of a destructuring binding or assignment expression.

>> missing semicolons. You get another case where programmers expect ASI
>> but there's no error to correct:
>>
>> x = y?
>> z:w
>>
>> where z is label and w is a statement that can syntactically (if not
>> sensibly) be labeled.
>
> ... or whatever other syntax. It's about Null Pattern idea, not the 
> actual syntax. 

Ok, but we need a concrete syntax that works if we want anything like 
CoffeeScript's suffix-? operator. And I agree suffix-? is attractive. 
But it seems like a non-starter based on the use of ? in ?: and : in 
labeled statements. Perhaps there's a tweak that saves this concrete 
syntax, though?

/be


More information about the es-discuss mailing list