Refutable destructuring

Brendan Eich brendan at
Sat Aug 10 13:15:04 PDT 2013

ES4 had this as "like" (at one point "is like"):

(arg1 like MyClass)

How deep this goes is one design decision; there are lots of others.

Pattern matching is more precise and flexible, and that's why we 
considered changing destructuring (which uses the pattern subgrammar) to 
refutable from irrefutable. Even now with destructuring irrefutable, 
patterns in catch clauses, match statements/expressions, or other future 
forms would want the same subgrammar, as much as possible -- but with 

Just doing 'like' and calling it a day isn't really enough. We know what 
it means, right? Like, totally!!! ;-)


Brian Di Palma wrote:
> It looks to me like there are people who want a sort of ducktypeof 
> operator.
> arg1 ducktypeof MyClass
> Which would return true if the shape of arg1 where the same as 
> MyClass. If I wanted to write as a refutable pattern I could end up 
> with a large block that may be repeated in several class methods.
> It would be nice to shorten that so that you could declare tersely 
> that your methods require a specific shape to be passed in.
> On Aug 10, 2013 1:47 AM, "Brandon Benvie" <bbenvie at 
> <mailto:bbenvie at>> wrote:
>     On 8/9/2013 5:45 PM, Allen Wirfs-Brock wrote:
>         and if we make U+2639 a special token that evaluated to throw
>         TypeError we could say
>            function foo( {a=☹ }) {}
>     This would be awesome.
>     _______________________________________________
>     es-discuss mailing list
>     es-discuss at <mailto:es-discuss at>
> _______________________________________________
> es-discuss mailing list
> es-discuss at

More information about the es-discuss mailing list