Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

IRC

Name: Anonymous 2009-11-06 19:17

irc.freenode.net ##C

Come join the fun

Name: >>57 2009-12-08 19:42

To elaborate on the issue some more, in C you have variable-argument lists, and you have the macros va_start/va_end/va_arg. They let you work with variable numbers of arguments. In practice, they're usually implemented as some macros which do some trivial pointer arithmethic on the stack (if the implementation uses a stack), but that requires the implementor of those macros (and probably compiler writer) to know how the compiler implements parameter passing. In some strange implementation of C, you could implement argument passing through CPS, or passing consed up lists or whatever, and the implementations of va_start/va_end/va_arg would differ, but if the implementation is standards compliant and the code is valid, portable C, then it will work just fine, as long as you don't assume things about memory layouts yourself.

Here's another example from another language:
The Common Lisp standard does not require tail-recursion optimization in implementations. Almost all serious implementations do perform this optimization. Scheme requires TCO.
It may be said that using tail-recursion to implement looping in Lisp is a bad idea as the standard leaves it open for implementations to break such functions, however in practice almost all implementations will let you write proper tail-recursive functions. The de-facto standard where almost all implementations perform this optimization means you can write such functions safely, even though the standard says that implementations aren't required to do it.

(This doesn't mean I'm a huge fan of tail-recursion for emulating iteration - I just use the proper iteration constructions most of the time.
It was just an example of a common point of debate.)

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List