| ▲ | sirwhinesalot 10 hours ago | |||||||||||||||||||||||||
I think local functions (like the GNU extension) that behave like C++ byref(&) capturing lambdas makes the most sense for C. You can call the local functions directly and get the benefits of the specialized code. There's no way to spell out this function's type, and no way to store it anywhere. This is true of regular functions too! To pass it around you need to use the type-erased "fat pointer" version. I don't see how anything else makes sense for C. | ||||||||||||||||||||||||||
| ▲ | gpderetta 9 hours ago | parent | next [-] | |||||||||||||||||||||||||
> There's no way to spell out this function's type, and no way to store it anywhere. This is true of regular functions too! well regular functions decay to function pointers. You could have the moral equivalent of std::function_ref (or similarly, borland __closure) in C of course and have closures decay to it. | ||||||||||||||||||||||||||
| ▲ | nutjob2 10 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||
The price you pay for GCC nested (local) functions is an executable stack with 'trampolines'. I'm a fan of nested functions but don't think the executable stack hack is worth it, and using a 'display' is a better solution. See the Dragon Book or Compiler Construction: Principles and Practice (1984) by Louden | ||||||||||||||||||||||||||
| ||||||||||||||||||||||||||
| ▲ | sylware 10 hours ago | parent | prev [-] | |||||||||||||||||||||||||
[dead] | ||||||||||||||||||||||||||