Anonymous methods

Andrea Giammarchi andrea.giammarchi at gmail.com
Wed Jan 11 12:56:58 PST 2012


I believe when we talk about lambda here, we don't exactly mean addressable
anonymous functions :-)

# python lambda
g = lambda x: x*x
g(8) # 64

// JS lambda
function lambda(exp) {
  var body = exp.split(":");
  return Function(body[0], "return " + body.slice(1).join(":"));
}

var g = lambda("x: x*x");
g(8); // 64
g.name; // anonymous

Regards

On Wed, Jan 11, 2012 at 7:29 PM, Allen Wirfs-Brock <allen at wirfs-brock.com>wrote:

>
> On Jan 11, 2012, at 10:10 AM, John J Barton wrote:
>
> The blog post  http://yehudakatz.com/2012/01/10/javascript-needs-blocks/ makes
> the case for blocks that act like functions when passed as arguments but
> have loop-up rules more like nested blocks.
>
> Of course these are called 'block lambdas', and I suggest that this is a
> problem. Given that very few programmers understand lambda calculus (and
> this will not change), the word 'lambda' is equivalent to "too difficult to
> understand".
>
> When I looked up lambda on http://en.wikipedia.org/wiki/Lambda I read
>
>   In mathematical logic <http://en.wikipedia.org/wiki/Mathematical_logic>
>  and computer science <http://en.wikipedia.org/wiki/Computer_science>,
> lambda is used to introduce an anonymous function<http://en.wikipedia.org/wiki/Anonymous_function> expressed
> with the concepts of lambda calculus<http://en.wikipedia.org/wiki/Lambda_calculus>
> .
>
> and then "Oh that is what they meant with all that 'block-lambda' stuff".
>
> If the discussion here were on a new ES feature "anonymous methods", then
> I guess many more developers would be interested. If this feature had the
> properties outlined in the blog post, then I think many developers would
> understand the value of this potential feature. As it is I guess they stop
> reading as soon as they see the word 'lambda'.
>
>
> Except that they aren't "methods" (a function that is associated with an
> object).
>
> If you want a name without "lambda" you might consider "block function" or
> "functional block"  indicating that we are talking about code blocks that
> may be passed and invoked as function values.
>
> Allen
>
>
>
>
>
>
>
> jjb
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120111/edd11fa4/attachment.html>


More information about the es-discuss mailing list