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.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of spaghetti

spaghetti

Photo of Preprocessor

Preprocessor

Photo of defer

defer

Related news:

News photo

How to wrap a C compiler and preprocessor, really

News photo

Python’s Preprocessor

News photo

Show HN: Preprocessor I've been working 4 years now