Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | jononanon@googlemail.com |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: va_arg... recursion: changing arguments and the using recursion |
| Date | 2012-04-26 12:44 -0700 |
| Organization | http://groups.google.com |
| Message-ID | <20174875.886.1335469448966.JavaMail.geo-discussion-forums@vbxz8> (permalink) |
| References | <6923270.398.1335376959698.JavaMail.geo-discussion-forums@vbcg6> <4F998F2F.9000906@verizon.net> |
Thanks for those explanations and the code.
On Thursday, April 26, 2012 8:08:47 PM UTC+2, James Kuyper wrote:
> #include <stdarg.h>
> #include <stdio.h>
>
> void go(int num, ...)
> {
> //...
> int p[num + 1];
Does this work with Microsoft compiler? I seem to remember that the MS compiler complained that it is not a fixed length array (given variable num) and thus didn't work.
Is this a C90 or c99 feature?
Wow I just realized that we have C11!
I've just read about TAIL RECURSION, where a stack can be essentially reused, if the last call of a function is the recursive call. Well then tail recursion with reuse of the stack is not possible in portable C, right?
Quoting from wikip. on "Tail recursion":
"Tail calls are significant because they can be implemented without adding a new stack frame to the call stack. Most of the frame of the current procedure is not needed any more, and it can be replaced by the frame of the tail call, modified as appropriate (similar to overlay for processes, but for function calls). The program can then jump to the called subroutine."
So how on earth can one reuse the stack, for the recursive call (that is e.g. realized as a jump), if I don't even know where the heck the stack is??
That was your message wasn't it: don't make any assumption on the location of the stack variables
So does this mean that a portable C version of code, using tail recursion which reuses the stack... cannot be done in C???
Thanks.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
va_arg... recursion: changing arguments and the using recursion jononanon@googlemail.com - 2012-04-25 11:02 -0700
Re: va_arg... recursion: changing arguments and the using recursion jononanon@googlemail.com - 2012-04-25 11:16 -0700
Re: va_arg... recursion: changing arguments and the using recursion James Kuyper <jameskuyper@verizon.net> - 2012-04-26 14:08 -0400
Re: va_arg... recursion: changing arguments and the using recursion jononanon@googlemail.com - 2012-04-26 12:44 -0700
Re: va_arg... recursion: changing arguments and the using recursion John Reye <jononanon@googlemail.com> - 2012-04-26 13:02 -0700
Re: va_arg... recursion: changing arguments and the using recursion John Reye <jononanon@googlemail.com> - 2012-04-26 13:13 -0700
Re: va_arg... recursion: changing arguments and the using recursion James Kuyper <jameskuyper@verizon.net> - 2012-04-26 16:28 -0400
Re: va_arg... recursion: changing arguments and the using recursion James Kuyper <jameskuyper@verizon.net> - 2012-04-26 16:34 -0400
Re: va_arg... recursion: changing arguments and the using recursion John Reye <jononanon@googlemail.com> - 2012-04-26 13:37 -0700
csiph-web