W3C home > Mailing lists > Public > public-script-coord@w3.org > July to September 2013

Re: [WebIDL] Callback functions and callback interfaces should allow optional arguments sanely

From: Cameron McCormack <cam@mcc.id.au>
Date: Tue, 23 Jul 2013 17:33:59 +1000
Message-ID: <51EE31E7.5020608@mcc.id.au>
To: Boris Zbarsky <bzbarsky@MIT.EDU>
CC: "public-script-coord@w3.org" <public-script-coord@w3.org>
Boris Zbarsky wrote:
> The grammar for callbacks allows optional arguments. But the processing
> model in
> http://dev.w3.org/2006/webapi/WebIDL/#es-invoking-callback-functions
> (which references the one in
> http://dev.w3.org/2006/webapi/WebIDL/#es-user-objects ) doesn't really
> describe what to do with such arguments. I would like to propose a
> processing model as follows:
>
> 1) Start with a list of n IDL argument values idlarg_{0 ... n-1}. This
> assumes that we have a way to represent a "not passed" optional value as
> an IDL type, which I believe we have agreed we need anyway.
> 2) Set argcount to n.
> 3) Set i to n-1.
> 4) While i >= 0 and the idlarg_i is not passed and the
> corresponding argument of the IDL callback type is optional:
> a) Set argcount to argcount - 1
> b) Set i to i - 1
> 5) Continue with the algorithm as currently defined, but using
> argcount, not n, as the number of arguments.
>
> We will also need to define that converting a "not passed" value to an
> ECMAScript value produces undefined, I think.
>
> Thoughts?
>
> -Boris
>
> P.S. I'm implementing the above in Gecko anyway, because it's needed to
> implement window.onerror. But I figured I'd at least sanity-check it.

That sounds reasonable to me.  I've allowed "missing" optional argument 
values in the middle of the argument list, as we've done for operations. 
  Also, I don't think we need to handle the case where a "missing" value 
is passed and the argument is not optional, since that shouldn't be allowed.

http://dev.w3.org/cvsweb/2006/webapi/WebIDL/Overview.xml.diff?r1=1.645;r2=1.646;f=h

http://dev.w3.org/2006/webapi/WebIDL/#es-invoking-callback-functions
Received on Tuesday, 23 July 2013 07:34:34 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:37:50 UTC