"lambda" is incorrect nomenclature

Description

A lambda in the accepted industry parlance is simply any anonymous function, it's got nothing to do with arrows vs more-verbose syntax.

The docs and implementation should be changed to reflect this. JS uses the term "arrow function" which I think is perhaps a better description. Whatever you use - just make something up, if you like - it should not be at odds with standard industry usage.

Activity

Adam Cameron 
11 April 2015 at 15:05

If we were talking about lambda expressions as they apply in maths: you'd have an excellent point there, Igal.

But we're not, so you don't.

-----------------------
Extracted from https://msdn.microsoft.com/en-us/library/0yw3tz5k.aspx#code-snippet-3:

````
delegate()
{
System.Console.Write("Hello, ");
System.Console.WriteLine("World!");
}
````

That's the syntax for declaring an anonymous function, inline, to fulfil a delegate contract. In CFML, the equivalent would be:

````
function()
{
echo("Hello, ");
echo("World!");
}
````

So, as I said, "They have a verbose syntax using the delegate keyword where CFML's equivalent would use the function keyword".

Igal Sapir 
9 April 2015 at 15:26

I disagree.

Lambda expressions come from math, where they were introduced decades before they found their way into the programming world.

// this is a lambda expression f = (x,y) -> x*y // this is not f = function(x,y){ return x*y }

Also, a delegate in C# is not an anonymous function, but a function pointer, something that some languages (like C and C++) have, but Java does not.

Adam Cameron 
9 April 2015 at 07:39

In the context of C#: yeah, OK, you have a point. They have a verbose syntax using the `delegate` keyword where CFML's equivalent would use the `function` keyword (the expression keyword though, not the statement one). And they have the arrow-based syntax which they reserve the word "lambda" to describe. Erroneously, IMO, but so be it.

In the context of Java though, there is only one syntax for defining anonymous functions (ie: lambdas), so they are not using the term lambda to differentiate between two syntaxes achieving the same thing. Java doesn't have the `function(){}` version of function literals. It only has the `->` version.

Bear in mind I am not contesting that "lambda expression" is a thing... it definitely is a thing... it's an anonymous function. What I am contesting that one ought to use "lambda" to differentiate between these two syntaxes:

````
// this is a lambda
f = (x,y) -> x*y

// but so is this
f = function(x,y){
return x*y
}
````

They're both lambdas. So using the word lambda to distinguish between the two is not very helpful, IMO.

Ruby has something called a lambda too, which is distinct from blocks, procs and methods which are all variations on the same theme (see http://www.reactive.io/tips/2008/12/21/understanding-ruby-blocks-procs-and-lambdas/). But IMO Ruby is an abject mess in this area, and should not be taken as a good example of how to go about things, much less emulated.

So in conclusion... whilst C# does set an unhelpful precedent, I still kinda think CFML would be better served by not using a non-standard usage of the notion of a lambda.

Andrew Dixon 
8 April 2015 at 20:34

@da_cameron I think you might be incorrect here as from what I have read the term "Lambda Expression", which is how Micha has referred to them seems to refer to this shorthand for functions:

https://msdn.microsoft.com/en-us/library/bb397687.aspx
http://www.drdobbs.com/jvm/lambda-expressions-in-java-8/240166764
http://www.javaworld.com/article/2092260/java-se/java-programming-with-lambda-expressions.html

Details

Assignee

Reporter

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Priority

Created 8 April 2015 at 08:08
Updated 14 November 2016 at 09:16