Hacker News new | ask | show | jobs
by timewizard 354 days ago

    typedef int fn_t(int, int);

    int iff(bool cond, fn_t a, fn_t b) {
        if (cond)
            return(a());
        else
            return(b());
    }
Now just write the implementation in terms of a() and b(). I don't get it. C doesn't have convenient syntax but this is compiled and not an evaluated language. This argument didn't make sense to me.
1 comments

I have the same issue with this article. I think it actually complains about the lack of inline anonymous function declarations.

The fact that you can't create functions at runtime is only due to needing a compiler. If you link your program against a compiler you can absolutely turn strings into code at runtime and then pass it around to other functions.