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

Quick Compiler Question

Name: Anonymous 2010-02-27 9:06

So I was thinking about C programs a short while ago, and a problem occurred to me.

Let's say that I have a function in which, say, we define a variable. It might look something like this:

int dicks (int cocks)
{
    int wangs;
    /* Do stuff to wangs and cocks here */
    return wangs;
}


Looking at int wangs; it seems that the compiler translates that line into "allocate space for an integer and return a pointer to it." If this is a case, is the compiler setting aside space for a new integer every time I run the function, or does it optimize by assuming that I'm only going to have one instance of it and just set aside space for a single int?

Whatever the answer to that previous question is, how would the compiler handle a recursive function? How would


Never mind, I'm an idiot. I forgot about registers and the stack for a second. I revoke my previous questions.

NEW QUESTION: What is the point of tail-call optimization? If all it does is convert recursive functions into iterative ones, why not just program them that way in the first place?

Name: >>3 2010-02-27 12:25

By real macros, I just meant what is known in Scheme as low-level macro. In its most basic form it's a function which is applied on a form whose CAR matches the macro name, and it returns a new expression which will be used in its place (macroexpansion is obviously recursive) when compiling or evaling. Using low-level macros in Scheme is less common since it's a Lisp-1, and that comes with its associated problems when dealing with low-level macros[1] (this is a non-problem in Lisp-n's), which is why hygienic macros are preferred in Scheme.

---
[1] - http://www.nhplace.com/kent/Papers/Technical-Issues.html

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