- From: Olli Pettay <Olli.Pettay@helsinki.fi>
- Date: Wed, 09 Nov 2011 00:03:54 +0200
- To: David Flanagan <dflanagan@mozilla.com>
- CC: public-script-coord@w3.org
On 11/08/2011 11:59 PM, David Flanagan wrote: > On 11/8/11 12:40 PM, Olli Pettay wrote: >> 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. >> > Its useful in *some* cases, but the vast majority of the cases, > developers just want to pass a function, not an object. I say make all > new APIs take a function only, and let developers use ES5 > Function.prototype.bind() when they want to specify a method. That's a > lot easier than having to remember whether the appropriate property name > is handleMutations, transactionStarted, or sample. If you just want to pass function, you can. But since implementations need to support useful { foobar: function() {}} syntax anyway, why not be consistent and support it always. Also, IMO, { foobar: function() {} } is significantly easier to understand than some prototype hackery. > > David >
Received on Tuesday, 8 November 2011 22:04:31 UTC