fwiw, I have few APIs that use null or undefined / void 0 as explicit
action to remove an item ... an example.

```javascript

function cookie(key, value) {
  if (arguments.length === 1) return get(key);
  if (value == null) return del(key);
  set(key, value);
  return value;
}

```

Although I would use `function cookie(...args){}` as soon as supported
and/or `arguments` would be undefined ... no big deal.

In the other case I would simply do something like:

```
function splice(a, b, ...rest) {
  var numArgs = rest.length + (b !== void 0) + (a !== void 0);
}
```

Not sure why this is so needed though.

Cheers



On Sun, Nov 10, 2013 at 12:59 PM, Allen Wirfs-Brock
<al...@wirfs-brock.com>wrote:

>
> On Nov 10, 2013, at 12:52 PM, Oliver Hunt wrote:
>
> > I don’t fully understand this — what is the reason for needing to know
> actual argument count?  The historical reason was that if i have a var arg
> function with a few required parameters i don’t have any nice way of
> iterating the optional args.
> >
> > Default and rest parameters seem to solve this use case.
>
> The legacy reason is that there are existing APIs that were probably
> originally implemented in C++ where the behavior of the function was
> determined by the number of passed arguments rather than by their actual
> values.
>
> The continuing reason is that WebIDL overloading model encourages people
> to design new APIs that have that same characteristic.  And so far, nobody
> has convinced the WebIDL maintainers to abandon such overloading as a
> specification technique.
>
> Allen
> _______________________________________________
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to