Function Syntax

Brendan Eich brendan at mozilla.com
Thu May 12 13:06:24 PDT 2011


On May 12, 2011, at 10:55 AM, Brendan Eich wrote:

> Ruby is far from simple, btw. Check out
> 
> http://samdanielson.com/2007/3/19/proc-new-vs-lambda-in-ruby
> 
> and the wikipedia page it references.
> 
> Looks like Proc.new but not lambda can return from its caller.

From http://en.wikibooks.org/wiki/Ruby_Programming/Syntax/Method_Calls it should be clear I was missing the "block" target. Blocks are syntactically restricted to being downward funargs. Only if reified as Procs do they potentially escape to be called later when their lexical parent method could have already returned.

IOW, blocks are restricted to being downward-funargs by syntax at their expression site, and by default in the callee (without the & before the corresponding formal parameter).

When we considered lambdas (the "Allen's lambda syntax proposal" thread from late 2008 to early 2009), we did not try to confine them syntactically to actual parameter lists. Did we miss a key restriction or feature of Ruby? I'm not sure, I'm too much a Ruby n00b.

/be


More information about the es-discuss mailing list