`this`: methods versus functions
rossberg at google.com
Thu Nov 10 06:48:38 PST 2011
On 10 November 2011 15:23, Axel Rauschmayer <axel at rauschma.de> wrote:
> I wonder if it made a difference if `this`was always stored in an
> environment (instead of an execution context). Then block lambdas could find
> them via the scope chain.
If I understand you correctly, then yes, this is definitely possible
in principle, and in fact corresponds to the standard model of objects
as straightforward records-of-closures (closing over `this'). But you
could not use prototypes directly anymore, because you would need to
close their methods over `this' as well when you construct an object.
IOW, this would require a more class-style approach to inheritance.
Of course, you can use that technique today, by simply never using
`this', and instead bind your own `self' explicitly. But obviously,
current engines will make object creation more costly that way.
More information about the es-discuss