- From: Cameron McCormack <cam@mcc.id.au>
- Date: Thu, 15 Dec 2011 12:25:56 +1100
- To: Ian Hickson <ian@hixie.ch>
- CC: "public-script-coord@w3.org" <public-script-coord@w3.org>, Anne van Kesteren <annevk@opera.com>
On 15/12/11 11:35 AM, Ian Hickson wrote: > I think that the sucky situation would be to have lots of places that take > callbacks, but have to keep looking up what the heck the function is > called in order to use the object form. I don't think it is unacceptable to have to know what name to use if you want to use the object form. > Consider an API that you can use whenever a callback is needed to track > the number of calls to the callback. If every callback uses a different > function name, you'd have to tell this API what the context of the > callback was instead of just being able to use it blindly. Consider what > it would take to change the implementation of such an API from using > closures to using an object to store data. Suddenly, every call site would > need to be updated to provide the callback method name. Is that a realistic usage scenario, that you have many callbacks all using the same function without caring about the particular type of callback that it is? What I see as the two possible arguments for allowing object-with-property for callbacks are: * you can store data on the object for the callback to use easily * you can store data on the object and have multiple callbacks using that same object, so that they can all share the same state easily (i.e., there are multiple callback methods on the object) If we use "handleEvent" everywhere, then that reduces the usefulness of object-with-property, since you won't be able to use the same handleEvent property as the callback function for different callback types. > Don't think of "handleEvent" as meaning "handle a DOM Event object". Think > of it as "handle an event", the event being "the callback was invoked". Yes, we can re-think what the name means like this. The particular name here doesn't concern me so much as the enforcement of a single name for all callbacks.
Received on Thursday, 15 December 2011 01:26:33 UTC