September 2003, rev. June 2017

A feature I wanted from C for years is still missing today: compiling code that is not written inside functions.

I want to write the following, compile it, and get back binary code:

int a = 1;
int b = a + 2;
printf("the sum is %d\n", b);

The reason I don't want to write this code inside a function is that the result won't be the same as writing the code outside it. With a function I'll need to make a function call. What I want instead is plain binary code the cpu can jump to.

And I want running this to be safe and easy. C could generate code that preserves the value of the registers it will need to use, without me having to tell C which registers these will be.

This isn't such a far fetched feature. A similar programming language called HolyC lets the user write code outside functions. So it's good to know this can be done. But it'd be great if C could do it too because then new languages could benefit from the decades of effort that went into the C compiler. Instead of writing a new compiler, new languages can generate C.

It'd also help if the C compiler could be linked in a program as a small library so a new language can call it without forking a new process.

(I also want C to add a bit type.)