W3C home > Mailing lists > Public > public-script-coord@w3.org > October to December 2011

Re: [WebIDL] Simplify callbacks

From: Olli Pettay <Olli.Pettay@helsinki.fi>
Date: Tue, 08 Nov 2011 22:40:41 +0200
Message-ID: <4EB993C9.7040805@helsinki.fi>
To: David Flanagan <dflanagan@mozilla.com>
CC: public-script-coord@w3.org
On 11/08/2011 10:23 PM, David Flanagan wrote:
> On 11/8/11 6:47 AM, Anne van Kesteren wrote:
>> It seems that all callbacks use handleEvent() and we cannot change
>> that at this point I think. We should simplify callback syntax to a)
>> make IDL easier to read and b) ensure consistency throughout the
>> platform.
>>
>> addEventListener(DOMString type, Callback(Event)? listener, optional
>> boolean capture)
>>
>>
> How about Callback means [Callback=FunctionOnly]. I.e.: you have to pass
> a function. New interfaces could use this.
We're trying to get rid of =FunctionOnly since there really isn't
any reason for that, and passing { the_name_of_the_callback: function() 
{}} is actually useful in some cases.


>
> And EventCallback means [Callback] EventListener. I.e. you can pass a
> function or any object with a handleEvent() method. Legacy APIs (and new
> Event apis) can use that.
>
> Some other thoughts:
>
> - If these are going to be parameterized with the argument type, it
> seems like the WebIDL precedent is angle brackets as in
> sequence<DOMString>.
>
> - If parameterized, will multiple arguments be supported? What about
> return values? Seems to me that that requires a lot of new specification
> in WebIDL and new functionality to add to IDL parsing tools, etc.
>
> - If these are going to be types defined by WebIDL itself, precedent is
> that they should start with a lowercase letter or be prefixed with DOM.
> (Hmm. "callback" could be the function only version and "DOMCallback"
> could be the legacy version that supports handleEvent() methods...)
>
> David
>
>
>
>
Received on Tuesday, 8 November 2011 20:41:10 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 May 2013 19:30:04 UTC