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

P T Withington ptw at
Thu Sep 11 08:40:08 PDT 2008

On 2008-09-10, at 13:36EDT, Mark S. Miller wrote:

>>> Or we could say that the property is looked up after wrapping, but a
>>> method call proceeds with the original unwrapped value. In other  
>>> words
>>>   "foo".capture()
>>> should be equivalent to
>>>   Object("foo")"foo")
>>> given the original bindings for Object and
>> 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.
> If we adopt the no-this-coercion rule and use wrapping only to explain
> the lookup, then the implied allocation above is unobservable and can
> easily be optimized away. By contrast, the allocation implied by the
> current spec can only sometimes be optimized away, and only by doing
> an escape analysis.

Will it be a problem that then `this` might sometimes not be an Object  
in a function?  If not, this is a clever refinement.

More information about the Es-discuss mailing list