1. Changelog
-
Initial release. ✨
2. Introduction and Motivation
Meow. :3
Bark. :3
3. Design
3.1. Nested Function Rehabilitations
int main () { int x = 3 ; int zero () { // OK, no external variables sued return 0 ; } int double_it () { return x * 2 ; // constraint violation } int triple_it () _Capture ( x ) { return x * 3 ; // OK, x = 3 when called } int quadruple_it () _Capture ( & x ) { return x * 4 ; // OK, x = 5 when called } int quintuple_it () _Capture ( = ) { return x * 5 ; // OK, x = 3 when called } int sextuple_it () _Capture ( & ) { return x * 6 ; // OK, x = 5 when caled } x = 5 ; return zero () + triple_it () + quadruple_it () + quintuple_it () + sextuple_it (); // return 74; // 0 + (3 * 3) + (5 * 4) // (3 * 5) + (5 * 6) }
Upsides:
-
Fixes ABI and allows Clang et. al. to implement.
-
Provides for explicit captures with a keyword.
-
Retains Nested Function look and feel.
-
Name mangling is less unclear (nested functions have a name, can be used to do recursion unlike Lambdas).
Downsides:
-
Nested Function is an "object" now, with a lifetime and a size? (No other function-like thing in C or C++ behaves like this!)
-
It’s still Nested Functions, GCC will keep their extension and obviously that lures people into executable stack issues.