jacob said:
Why would it matter?
suppose that as the last action you make
return sameproc(2,3,&local);
Since the value of "local" can't ever be used after
the call returns, it doesn't matter at all.
I'm afraid you are mistaken, since the address of `local` can be used
/inside the call of `sameproc`/. Hence it's important that `local`
continue to exist, hence (in the usual implementation) that the
stack frame it's in continues to exist, hence you can't do the
straightforward stack-frame elimination part of tail-call optimisation.
Consider this horrible sketch of an example:
Answer example( Args x, struct Ex *uplink )
{
if (terminationCondition( x ))
{
return dependsOnUplinkChainAndX( x, uplink );
}
else
{
struct Ex another;
another.uplink = uplink;
another.stuff = hackeryOn( x );
return example( shrink( x ), &another );
}
}
The recursive call can't be TCOd; the number of `another` elements
needed depends on how much `x` needs to be shrunk before meeting
the termination condition, so you can't junk the stack frames.