Refutable destructuring

Brandon Benvie bbenvie at mozilla.com
Fri Aug 16 14:31:00 PDT 2013


On 8/16/2013 2:08 PM, Domenic Denicola wrote:
> Actually, I think it'd be fantastic to have an easy way to communicate required parameters in an options object.

I agree and this is why I was a fan of Axel's +/! "this is required" prefix.

One of the reason's JS is so popular is because hard failure is opt-in. 
That is: by default the language will not punish you for mistakes made 
as a noob/while developing. You can access a non-existent property, for 
example, without it destroying the whole program. This is, of course, 
also a source of subtle and hard to diagnose bugs. But, on balance, I 
think it's worth it for what JS is meant to do.

That doesn't mean we can't have opt-in strictness, though. This is why I 
love Axel's proposal: you *can* opt-in for strictness and get the 
guarantees you want. This is the same reason TypeScript exists, and has 
gained such a following. TypeScript is to ECMAScript as refutable 
destructuring is to Axel's proposal.


More information about the es-discuss mailing list