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

Re: [WebIDL] Simplify callbacks

From: Brendan Eich <brendan@mozilla.org>
Date: Tue, 8 Nov 2011 14:43:29 -0800
Cc: David Flanagan <dflanagan@mozilla.com>, public-script-coord@w3.org
Message-Id: <AD20A7A8-B386-4961-8974-ED7F27A3AEAE@mozilla.org>
To: olli@pettay.fi
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

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