Get the latest tech news
Braiding the spaghetti: implementing defer in the preprocessor
I already talked about a proposal for an extension of the C language calleddefer, that is prospected to either be published in a technicalspecification or the next revision, C2Y, of the C standard:…
EĿlipsis now implements a simple form of this feature by mixing some specific preprocessor extensions (in particular counters) with the usual macro magic. For this simplified example the idea is that all statements that are prefixed with defer are executed at the end of the function in the reversed order in which they appear lexicographically. EĿlipsis enables a simple form of this and the point of this blog entry here is to show that already a slightly enhanced preprocessor can be used to hide all that complexity from the programmer.
Or read this on Hacker News