return when desugaring to closures

Peter Michaux petermichaux at gmail.com
Sat Oct 11 09:11:08 PDT 2008


On Fri, Oct 10, 2008 at 7:28 PM, Yuh-Ruey Chen <maian330 at gmail.com> wrote:

> I wonder if we really need named lambdas in the first place. I consider
> the whole named function/let/var thing to be messy enough already. Is it
> really that too difficult to do this:
>
> let f = lambda() { ... }
>
> And if predictable recursion is an issue, you can always do this
> (assuming this form is in ES-Harmony):
>
> let (f = lambda() { ... }) ...
>
> I don't consider keeping symmetry with named functions to be a
> convincing argument, since the proposed named lamda works on the block
> level rather than the function level, unlike named functions. There's
> bound to be confusion regardless.

I think it would be ok to have only unnamed lambdas. (It would be ok
to have named lambdas too.)

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;
})();

Peter


More information about the Es-discuss mailing list