Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

GNU C has had nested functions for quite a long time. I would use them a lot if they were standardized. https://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html


D's differs in that:

1. you cannot "goto" out of the nested function

2. you can declare them "static", which means they don't have a static link and cannot access the enclosing function's variables

3. if garbage collection is enabled, you can pass a pointer to the function out of the enclosing function's scope and still safely access its variables

4. they work in `extern (C++)` functions, too




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: