Comment

Comment by enriquto

A beautiful, and simple, addition to the C language would be a mechanism to assess the remaining stack size. This is trivial to check in assembler, but practically impossible in portable C.

Indeed, thanks to VLA, the stack can be used as a clean notation for raii. You just replace this ugly, but very common, construction

    void f(int n)
    {
            float *x = malloc(n * sizeof*x);
            // ...
            free(x);
    }
with this

    void f(int n)
    {
            float x[n];
            // ...
    }
parent enriquto 8 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton