[Main]
Title=How can I make my C function return itself?

[Top]
<TABLE CELLPADDING="4"><TR><TD VALIGN="TOP"><B>Q:</B></TD><TD>
Suppose I'm writing an ASM function <CODE>'foo(n)'</CODE> which accepts an
argument (a string, for example). I want to make <CODE>'foo(n)'</CODE>
return <CODE>'foo(n)'</CODE> (the call itself) when <CODE>'n'</CODE> is of type
"VAR" (i.e. if nothing has been assigned to <CODE>'n'</CODE> yet)...
</TD></TR><TR><TD VALIGN="TOP"><B>A:</B></TD><TD>
This is quite easy, if you know in advance the name of the program.
Suppose, that your program name is "example". Here is the demo (called
"Function Returning Itself") which will return <CODE>'example(n)'</CODE> if
you type <CODE>'example(n)'</CODE> if
<CODE>'n'</CODE> is a variable, and which will return the string "blabla"
(for example) if the argument is something else:
$$EXAMPLE(Function Returning Itself.c)
Note that this solution is not ideal: if you rename the program name to something else,
the function will still return <CODE>'example(n)'</CODE>. It
<I>is</I> possible to determine the real name of the program in the run time, but this
is very awkward.
</TD></TR></TABLE>
