return when desugaring to closures

David-Sarah Hopwood david.hopwood at industrial-designers.co.uk
Sat Oct 11 11:41:07 PDT 2008


Peter Michaux wrote:
> On Sat, Oct 11, 2008 at 10:02 AM, Mark S. Miller <erights at google.com> wrote:
>> On Sat, Oct 11, 2008 at 9:11 AM, Peter Michaux <petermichaux at gmail.com> wrote:
>>> As it stands, I always write the following in ES3
>>>
>>> var f = function() {};
>>>
>>> and now that arguments.callee is on the chopping block, I've started
>>> writing recursion as the painful contortion below
>>>
>>> var f = (function() {
>>>  var callee = function() { callee(); };
>>>  return callee;
>>> })();
>> I don't get it. Why not write
>>
>>   var f = function() { f(); };
> 
> var f = function() {f();};
> var g = f;
> f = function(){alert('broke your recursion :)');};
> g();

/*const*/ var f = function() { f(); };

Then just treat /*const*/ variables as if they were 'const', until
at some point you no longer care about old versions of JScript and
can globally replace '/*const*/ var' -> 'const'.

-- 
David-Sarah Hopwood


More information about the Es-discuss mailing list