Enforcing arity?

Brendan Eich brendan at mozilla.com
Mon Jan 7 11:33:53 PST 2013


Jason Orendorff wrote:
> On Sun, Jan 6, 2013 at 6:31 PM, Axel Rauschmayer <axel at rauschma.de 
> <mailto:axel at rauschma.de>> wrote:
>
>     What is the simplest way of enforcing an arity in ES6? Doesn’t it
>     involve arguments?
>
>
> Hmm. Can you do this?
>
>     function f(x, y, ...[]) {}

The question is, with refutable-by-default, does the empty array pattern 
fail on any non-empty arraylike match target? If yes, then we need a way 
to match prefixes of arraylikes (including empty prefixes!):

   let [] = must_be_empty();
   let [...many] = however_many();
   let [first?, second?] = two();

I buy it!

/be


More information about the es-discuss mailing list