Re:Guide to modern Object Pascal for programmers
by Artlav on Monday July 04, 2016 @08:00AM
(#12030195)
Why do you want closures for the web code? What do they add? What is hard to do without them?
[ Parent
| on HN ]
Re:Guide to modern Object Pascal for programmers
by amelius on Monday July 04, 2016 @08:11AM
(#12030225)
To handle event call-backs. Generally, inside an event-handler, you want access to variables in a higher scope.
Re:Guide to modern Object Pascal for programmers
by mhenr18 on Monday July 04, 2016 @09:20AM
(#12030567)
Two things:
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.