

First Class Functions in C - Because That's Totally a Good Idea - 4ad
http://zenhack.net/2013/09/04/first-class-functions-in-c-because-thats-totally-a-good-idea.html

======
dezgeg
I've implemented the exact same thing once, and found out later that it really
doesn't work.

The problem is that the caller cleans up the stack in the 32-bit ccall calling
convention.

For example, when main calls write_stdout("foo", 3) it will push 3 and "foo"
to the stack. The generated stub pushes 1 to the stack, and jumps into the
write() function. After write() returns, main() pops off the 2 parameters it
pushed, and now the stack is misaligned since no-one popped the parameter
pushed by the generated stub.

------
mehrdadn
[http://stackoverflow.com/questions/12136309](http://stackoverflow.com/questions/12136309)

