Re: whether [Callback=FunctionOnly] should be the default

On Tue, 28 Jun 2011, Boris Zbarsky wrote:
> 
> This pattern doesn't work well if what you want is to encapsulate state 
> including a given prototype chain and the like.  Sure, you can hack it 
> all with a closure because you can just close over everything you care 
> about and delegate things, but in some cases having an actual object 
> which ends up as the this of the callback and has a useful prototype 
> chain and whatnot is just much clearer.

This is probably just a personal preference thing. Personally I've never 
really found the prototype mechanism in JS to be especially intuitive and 
so the idea of using it in this way frightens me. :-)

One big advantage of FunctionOnly is that the code that uses the API 
cannot do complicated things such as what you describe, thus making code 
that uses the API simpler to understand, IMHO.

But that's rather subjective, I'll be the first to admit.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Tuesday, 28 June 2011 23:02:12 UTC