Short Functions

Brendan Eich brendan at
Sun May 22 16:36:09 PDT 2011

On May 22, 2011, at 4:05 PM, Brendan Eich wrote:

> That block-lambdas look like blocks not function expressions is pretty much the whole point. I don't think you addressed it.

To reverse the argument you made: if function body looking like a block were a source of confusion, we'd already have trouble:

function outer() {
  var answer;
  if (life_universe_everything) {
    answer = function () { return 42; }
  } else {...}
  return answer;

But people do not read the return above as returning from function outer. Why not? Not sure, maybe they learned the hard way. More likely, the distinctive function () head syntax before the body block made it clear.

Distinctiveness is important. This is why I argue anything with TCP purity about break, return, continue, |this|, and arguments should look quite unlike a function expression. In conjunction with the control absraction support idea that wants paren-free block-argument-bearing calls, it favors something very much like block lambdas (or lighter, if possible).

But anyway, function bodies are not mistaken for blocks. Block lambdas are meant to look like blocks, in a good way. They could be abused, for sure. That's not sufficient reason to reject 'em, though.


More information about the es-discuss mailing list