This is the mail archive of the guile@cygnus.com mailing list for the guile project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
> C compilers *cannot* be properly tail recursive without a change in > calling conventions because the caller pushes & pops args off the > stack. You cannot jump to the routine because the routine won't clean > up the stack itself. If you were to change the calling conventions to > support this, then a) you'd also have to add a stack size argument to > all calls so that the routine knows how much to pop (to support > varargs), and b) you'd be incompatible with all libraries. Right. You need to design the ABI so that the caller doesn't make any assumptions about how many arguments there will be on the stack upon return, because the callee (and the callee's callee, etc.) is going to create argument lists for who-knows-what in the same space. In my day job, I've been working with the PowerPC ABI; under those rules, there will simply be some times that you can't optimize some tail calls. There's been talk at the FSF about adding to EGCS an attribute to functions designating them as tail-call-friendly. They'd use a different ABI, and callers would see that declaration, and pass arguments in a nice way. But I don't think anyone's done it.