Re: [WebIDL] Simplify callbacks

On Nov 8, 2011, at 2:03 PM, Olli Pettay wrote:

> On 11/08/2011 11:59 PM, David Flanagan wrote:
>> 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.

The problem is 'foobar' is not consistently defined as one name, or a set of names whose parts can be derived from an obvious set of rules.


> Also, IMO, { foobar: function() {} } is significantly easier to understand than some prototype hackery.

What prototype hackery?

  (function (e) {...}).bind(o)

involves no prototype hackery.

/be

Received on Tuesday, 8 November 2011 22:44:06 UTC