Basic Lambdas and Explicit Tail Calls Repackaged

Brendan Eich brendan at
Sun Dec 7 23:56:11 PST 2008

On Dec 7, 2008, at 11:51 PM, Brendan Eich wrote:

> More concise function syntax is not a goal solely, or even  
> exclusively,

Er, I meant non-exclusively.

> to support user-defined control abstractions. It's a good in its own  
> right unless you consider every use of a function expression in JS  
> today to be a control abstraction in the Smalltalk block sense (I do  
> not).
>> In some cases in strict mode 'this' will be undefined instead of  
>> being the global object, does this come close enough to omitting  
>> 'this' for functions which are not methods?
> Not really -- strict mode does not change the ability of |this| to  
> be rebound in the absence of Function.prototype.bind usage, which  
> has its costs, and which apart from overhead in implementation  
> terms, takes too long to say in the language to be likely as a  
> default practice. Sure, Ajax libraries use it well, but it's still  
> observed more in the breach looking at the whole of "web JS".

IOW, without a sugared syntax for bound methods (instance methods in a  
class, say), |this| is still dynamically bound depending on call  
expression. Passing undefined for some cases does not get rid of the  
"which this?" confusion.

I would be surprised if we ever evolved a version that lost the  
default this binding whereby

var o = {m: function(){print(this.x);}, x: 42};

worked as it does today, without requiring heavy analysis or any  
incompatibility. We might someday hope, in the default version, to  
censor the global object, if we are lucky. Mark wrote about this  
recently in raising the prospect of Harmony being a successor to 3.1- 
strict, not 3.1.

One mountain at a time...


More information about the Es-discuss mailing list