3 ms·
It doesn't make sense that a language that compiles to C can't support nested functions, just because C doesn't. All the transpiler has to do is invent a globa
by unwind 12y ago
It doesn't make sense that a language that compiles to C can't support nested functions, just because C doesn't.
All the transpiler has to do is invent a globally unique name for each function, for instance. Of course they might not have implemented it yet, but there shouldn't be any firm reason why it can't be done.
- masklinn 12y ago> All the transpiler has to do is invent a globally unique name for each function, for instance. I would expect nested functions to close over their context. Still implementable in C of course (or ghc -fvia-c wouldn't work), but not as trivially.
- adrusi 12y agoProcedures can appear at the top level in a module as well as inside other scopes, in which case they are called nested procs. A nested proc can access local variables from its enclosing scope and if it does so it becomes a closure. From the manual: http://nim-lang.org/manual.html#closures http://nim-lang.org/manual.html#closures