Coercing 'this' (was: Topic list - pending changes and issues for the ES3.1 spec)

Brendan Eich brendan at mozilla.org
Thu Sep 11 11:19:20 PDT 2008


On Sep 10, 2008, at 3:07 AM, Sam Ruby wrote:

> In such a scenario, is there value in providing a Decimal wrapper type
> at all?

So people can add methods that we did not think of to  
Decimal.prototype. But you assumed static methods only, so perhaps  
you meant to exclude this use-case.

Extending standard constructor prototypes is frowned upon currently  
because such user-defined prototype properties are enumerable, but  
Object.defineProperty/ies stand ready. And people do use this use- 
case today, whether we like it or not.


> It occurs to me that the latter case (looking up after wrapping)
> trades a single wrapping at function entry against potentially
> multiple wrappings that may occur inside the function.

Wrapping must be done at most once, lazily on first |this| use if  
possible but at most once only, per |this| parameter binding.

/be



More information about the Es-discuss mailing list