statement is going mainstream. Go has it's own special defer which only fires on function end, otherwise defer
has consistent "execute at scope end" semantics. Swift, Zig
, Jai, Nim
all use defer in this manner.
The problems with implementing defer
is similar to implementing destructors for stack allocated objects in C++, although the presence of virtual functions complicates things.
I couldn't find anyone describing how defer
is done in other compilers so when working on a version of it for C2
I had to make it up as I went along.
For posterity's sake I ...
Read More →