Re: Reconciling handling of optional arguments and handling of default values across ES and webidl

On Thu, May 9, 2013 at 8:20 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote:
> On 5/9/13 5:06 PM, Garrett Smith wrote:
>> drawImage specifies its overload sets (3, 5, 9). Why can't webIdl
>> overload can match the algorithm for that without checking argument
>> types?
>
>
> In this case it does.  Argument type checking only comes into play when more
> than one possible overload matches the passed-in argument count.
>
> And again, for purposes of the undefined discussion what really matters here
> is whether trailing undefined should be counted or not for purposes of the
> argument count for this algorithm.  I guess if we leave arguments.length
> as-is in JS then they should be, for consistency....

We should make the choice of behavior here based on what creates the
most useful/intuitive/consistent API, not based on what
arguments.length contains.

Whatever arguments.length does, any of the options here could be
implemented in JS. I.e. JS code could either check arguments.length,
or it could check which of the arguments had the value 'undefined'.

What makes figuring out what's most useful/intuitive/consistent tricky
in this case is that I don't think that anyone would create a JS API
like this.

/ Jonas

Received on Friday, 10 May 2013 06:45:12 UTC