Re:How an Engineering Company Chose to Migrate to D
by WalterBright on Wednesday June 20, 2018 @03:20PM
(#17358789)
D nested functions are defined exactly like regular functions, including all attributes, parameter types, etc. There's nothing new to learn.
My experience as a language designer is that syntax matters, and leveraging the users' existing knowledge is worthwhile.
Rust does support nested functions that don't close over their environment, and has a separate syntax for closures which do, and closures can either move or borrow their captured variables. This makes it a bit harder to write a translator that produces good, idiomatic results; you could always use a closure that borrows the closed over variables, which I think matches the Pascal semantics, but that would mean the code would look a little odd for cases in which you had a nested function just to factor out some functionality and didn't need the closure.