Unfortunately, with closures you need good memory handling. And this means either a complicated type-system such as Rust's, or a garbage collected environment. The way C++ does closures is too dangerous for event-driven code, imho.
Unfortunately, with closures you need good memory handling. And this means either a complicated type-system such as Rust's, or a garbage collected environment. The way C++ does closures is too dangerous for event-driven code, imho.
Delphi has closures, FPC is on development, but in the end I won't use it much. I need performance and maintainability, closures are against those two.
They're called Anonymous Methods in Object Pascal:
http://docwiki.embarcadero.com/RADStudio/Berlin/en/Anonymous...
Free Pascal doesn't support them yet.
1. You don't need closures at a language level to do event callbacks. Just the ability to refer to functions by reference and call those references. Closures certainly make it syntactically nicer, but you can work without them.
2. You don't need event callbacks in a webserver to make it performant. The memory/CPU overheads needed to make closures work are essentially identical to what's needed to make blocking threaded code work, as long as the threading is done in userspace and you have support for expanding stacks. Even if you don't have support for those niceties, modern kernels and hardware are perfectly capable of handling thousands of OS-level threads.