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
refutability.
Just doing 'like' and calling it a day isn't really enough. We know what
it means, right? Like, totally!!! ;-)
http://slang.soe.ucsc.edu/cormac/papers/valleyscript.pdf
/be
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" <[email protected]
<mailto:[email protected]>> 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
[email protected] <mailto:[email protected]>
https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss