How Do I Make This Hard to Misuse?
Posted Apr 1, 2008 11:14 UTC (Tue) by
jzbiciak (
✭ supporter ✭, #5246)
In reply to:
How Do I Make This Hard to Misuse? by xbobx
Parent article:
How Do I Make This Hard to Misuse?
Sounds plausible (and quaint!), but I'm not sure I'm following the scenario. I'm interpreting "reverse order" as "left most argument pushed last." So, suppose putchar(int c) is a wrapper around fputc(int c, FILE *f):
int putchar(int c)
{
return fputc(c, stdout);
}
So, in pseudo-code, the resultant assembly ought to look roughly like this (assuming tail-call optimization):
POP 'c' into a register
PUSH 'stdout'
PUSH 'c' back on stack
JUMP to fputc and let it return for us.
It seems like if arguments went in reverse order, then adding the FILE * argument at the beginning would be the optimization:
PUSH 'stdout'
JUMP to fputc and let it return for us
I must be missing something.
(
Log in to post comments)