5 ms·
Rust's closures are, well, closures. But many of them are effectively lambdas. It's not like we can force you to refer to your environment or something :p "A c
by steveklabnik 10y ago
Rust's closures are, well, closures. But many of them are effectively lambdas. It's not like we can force you to refer to your environment or something :p
"A closure with an empty environment" vs "a lambda" is a fine, barely-existent line. Or arguably identical.
- cwyers 10y agoWait, what? A closure can be a lambda and a lambda can be a closure, but you can have closures that aren't lambdas and lambdas that aren't closures. Why link them together at all? "A closure with an empty environment" is only a lambda if it's unnamed, otherwise it's just a function.
- kibwen 10y agoI think the burden of proof is the opposite: why not link them together? What are the benefits of having closures and lambdas be two distinct language features when having just one seems to suffice (specifically, having a lambda be a degenerate closure)? As for naming, that's an orthogonal issue, as a closure can be anonymous just as easily, and I see no use in drawing a semantic distinction between anonymous "lambdas" and nonymous "functions".
- cwyers 10y agoWhat on earth are you talking about? The definition of "lambda" is "anonymous function." Naming is orthogonal to closures, yes, but it's the entire difference between a lambda and any other kind of function. A lambda can close over state or not, it doesn't matter. It just needs to not have a name. So if naming is orthogonal to closures, then lambdas are orthogonal to closures, and then it makes no sense to compare them.
- kibwen 10y ago> The definition of "lambda" is "anonymous function." > A lambda can close over state or not, it doesn't matter. I've never heard of any definition of "function" that allows closing over state, that's the demarcation that we use to distinguish a function from a closure. What taxonomy are you trying to propose? And going back to my original question, what is the practical intent of trying to make a lambda a semantically-distinct concept from a closure?
- cwyers 10y agohttps://wiki.haskell.org/Anonymous_function https://wiki.haskell.org/Anonymous_function https://wiki.haskell.org/Closure https://wiki.haskell.org/Closure
- Dylan16807 10y agoIn the phrase "anonymous function", "function" means anything that you can call. This includes closures. I'm very surprised you've never heard of the word "function" being used that way.
- saghm 10y agoI guess in my mind, "a closure with an empty environment" is a contradiction, but as mentioned elsewhere in the thread, there isn't a lot of consistency to the way we use these types of terms (closure, lambda, etc.) across different languages and paradigms.
- steveklabnik 10y agoYup. I also think it matters if you come at it from an implementation angle or a math angle. It's a contradiction from the latter, but from the former, it may not be. Maybe I'll write a blog post.