4 ms·
Questions? You got any idea why people hate the concept of nested functions in C? Why named named arguments test( a:4, b:3) instead of test(.a=4, b.=3); Have
by Gibbon1 2y ago
Questions?
You got any idea why people hate the concept of nested functions in C?
Why named named arguments test( a:4, b:3) instead of test(.a=4, b.=3);
Have any idea how you would handle first class types in C.
- WalterBright 2y ago> You got any idea why people hate the concept of nested functions in C? No, I was surprised to hear it. > Why named named arguments test( a:4, b:3) instead of test(.a=4, b.=3); Consistency with how static initializers work in D.
- kloop 2y ago> You got any idea why people hate the concept of nested functions in C? It breaks the model of c mapping to the hardware. Functions in C are just labels you jump to. Assuming you want to capture values from the environment you're defining the function in, you have to implement some sort of function struct that is callable, and it probably won't work with any shared libraries on your system. Also it would be slightly slower, and C programmers tend to not be willing to make that tradeoff
- WalterBright 2y agoD (and Pascal) implement it by adding and additional parameter to the function called the "static link". (The stack pointer is the "dynamic link".) The static link points to the stack frame of the function it is lexically nested inside. The compiler accesses the variables by offsets to the static link.
- pkphilip 2y ago> Why named named arguments test( a:4, b:3) instead of test(.a=4, b.=3); Why do you consider the second one better than the first (a:4, b:3)?
- lsllc 2y agoIt (the 2nd one) mirrors C's designated initializers for structures: struct foo f = { .bar = 1, .baz = 2, };