3 ms·
Well, C++ has lambdas with explicit capture list. A captureless lambda is basically a function (it even converts to a function pointer), otherwise it's a closur
by leni536 4y ago
Well, C++ has lambdas with explicit capture list. A captureless lambda is basically a function (it even converts to a function pointer), otherwise it's a closure.
- keybored 4y agoWell, what? My objection is calling a closure for “nested function”, a term I’ve never seen for such a thing.
- dragonwriter 4y agoI've seen nested function, whether or not it is also a closure, for ever; a closure is a function with an associated environment; a nested function is a function defined within another function.
- kevingadd 4y agoC# has "local functions" [1], and i feel like "nested function" is an equally good name for the concept [1] https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/local-functions https://learn.microsoft.com/en-us/dotnet/csharp/programming-...
- lmm 4y agoIt's a very natural and obvious term (far more natural than "closure" IMO). The wikipedia page has citations going back at least 20 years.
- keybored 4y agoYou win.
- shultays 4y agoEh, closure is just anested function. Just like a function can have access to global/static vars, a closure can also have access to vars in its parent scope. They are like global vars to it