News for hackers. Stuff that matters.
Re:Closures and Objects Are Equivalent (2013) by IshKebab on Sunday November 20, 2022 @07:56AM (#33680546)
> Function objects may close over nothing

So you're saying a closure that happens to not close over any variables is no longer a closure? I don't think many programming languages agree with that. For instance C++: https://en.cppreference.com/w/cpp/language/lambda or Rust: https://doc.rust-lang.org/book/ch13-01-closures.html

They both use "closure" in all cases even if the function doesn't actually bind any scope variables.

We don't have a special name for functions that take 0 parameters. I don't think a special name is warranted here either.

Re:Closures and Objects Are Equivalent (2013) by morelisp on Sunday November 20, 2022 @08:14AM (#33680663)
Not sure what you're saying, Rust specifically calls out the degenerate case of "closures" as having very different behavior:

Non-capturing closures are closures that don't capture anything from their environment. They can be coerced to function pointers (e.g., fn()) with the matching signature.

There's value in deference to practicality - we want to treat n-ary closures and n-ary functions the same way much of the time so we should make it easy to write functions which accept both which means they should be nameable via the same succint type - but we also shouldn't confuse that practicality for formalism.

> We don't have a special name for functions that take 0 parameters.

Only because we have generalized "nullary", "unary", etc. We know that e.g. a nullary pure function must also be a constant function. There are similar useful implications we can draw for "non-capturing closures" that makes them a distinct type in the formal sense, even if not in the "this is the type a particular language attaches to the resulting variable/value" sense.

But what does any of this have to do with your original point? I don't think anyone claimed closures aren't a kind of function, only that "function objects" is not synonymous with them. Most languages, including obviously Rust and C++, have functions objects which aren't closures