4 ms·
One suggestion - it isn't worth using the archaic "lambda" to mean a function. You could use "function" or some abbreviation of it like "fn" or "fun".
by sriku 6y ago
One suggestion - it isn't worth using the archaic "lambda" to mean a function. You could use "function" or some abbreviation of it like "fn" or "fun".
- jhardy54 6y agoI'd be interested to hear why you were downvoted. Maybe lambda refers to arrow functions rather than convention 'function' functions?
- BalinKing 6y agoAt least in my personal experience, I strongly disagree that "lambda" is archaic... admittedly it might just be me (or maybe my specific background as a Haskeller), but I call anonymous functions "lambdas" all the time.
- sriku 6y agoThere is enough justice done to the term in Haskell. Won't blame you for it. But other languages aren't on the same footing.
- lolinder 6y agoLambda is far from archaic. I call them lambdas all the time. Python explicitly uses lambda as the keyword. Java, C++ and Kotlin all use "lambda" to describe closures in the official docs. Rust uses both closure and lambda. All of these languages except python either are new (Rust, Kotlin) or have had lambdas added in the last ten years.
- sriku 6y agoThe fact that "lambda" came from "lambda calculus" is of such little relevance to mainstream programming today that we don't need to be reminded of it every time we want to write an "anonymous function". IMO, Clojure did the right thing there. I'm not against the concept of lambdas (obviously, I love them since I made a scheme dialect with them for video editing). The word today is too specific for a plethora of subtly different representations/implementations of the "lambda" of "lambda calculus". If "lambda" is supposed to mean "function", choose "function". No harm done.
- didibus 6y agoActually in Clojure I tend to distinguish: Anonymous function: (fn [a] ... a) And lambda: #(... %) I don't think this is official nomenclature, but I've been using that to distinguish between both syntaxes. In truth though, anonymous functions is the more accurate terminology, because lambdas are actually not functions, they're supposed to curry and use term substitution. Where as most programming languages use anonymous functions, which support multi-arity and sometime even variadic arity, and don't use term substitution, but more common argument binding.
- fulafel 6y agoTrivia: You can name fns: (map (fn first-or-last [x] (or (first x) (last x)) my-seq) (Of course the name has no semantic effects as you can't refer to it from code, but it's there in debugging / stack traces and serves as a comment for the reader).
- didibus 6y agoActually you can refer to the name inside the anonymous function for self-recursion I believe.
- steveklabnik 6y agoRust should only use "closure," lambda isn't used as far as I know. (I spent a bunch of time trying to sort this terminology when writing the book.) That said, I don't really know if I'd agree that it's archaic, just less common. Python being an extremely popular language that uses it explicitly (as you say) makes it hard to really suggest that it's archaic.
- lolinder 6y agohttps://doc.rust-lang.org/stable/rust-by-example/fn/closures.html https://doc.rust-lang.org/stable/rust-by-example/fn/closures... First paragraph here uses both. I suspect that they use closure throughout the rest of the article, but the fact that they feel the need to reference the other name shows that lambda is still in common currency.
- steveklabnik 6y agoGotcha, thanks.
- markussss 6y agoMy understanding here is that you can just configure this to your own liking. If you don't like lambda, just (macro fn lambda) and you're set. The names chosen by the original writer doesn't really matter when you can reconfigure the language.
- an_ko 6y agoYou can use "function" too. There are 2 because JavaScript has 2 different structures for making functions; function expressions (which I chose "lambda" for) and function declarations (which I chose "function" for). See https://github.com/anko/eslisp/blob/master/doc/basics-reference.markdown#functions https://github.com/anko/eslisp/blob/master/doc/basics-refere... for examples. Function declarations are statements, and you need to provide a name for the function. Function expressions are expressions, and the name is optional. In practice they often end up being interchangeable, but I just wanted to make sure any JavaScript is definitely representable.
- yvdriess 6y agoTechnically, a function is a named lambda. There are subtle implications for both in PL design, so it's important to keep the naming distinct.
- sriku 6y agoI suppose I should've just said "it isn't worth using "lambda" to mean a function". Too many comments latched on to "archaic" instead of the intended point.