Basic Lambdas and Explicit Tail Calls Repackaged

Brendan Eich brendan at mozilla.com
Tue Dec 9 10:24:14 PST 2008


On Dec 9, 2008, at 3:23 AM, Michael Day wrote:

> Functions are mutable objects and could perhaps gain a potential  
> speed boost in some circumstances by being immutable. But that could  
> be achieved by a generic mechanism for making immutable objects, and  
> does not require introducing a new type of function.

ES3.1 has Object.freeze, but you have to call it. This is ineffecient  
and slightly hazardous, compared to a declarative form that makes an  
immutable function from the start. The other advantage, of course, is  
better syntactic UI -- sweet sugar. Opinions vary on what's sweet, but

function dontMessWithMe() { ... }
Object.freeze(dontMessWithMe);

is not, especially if you do it hundreds of times (because you want  
almost all your functions to be immutable).

/be


More information about the Es-discuss mailing list