On 12/06/17 09:19, Chris Marusich wrote:
I think I'm missing something here. In (list (f)), the call to f
certainly looks like it's happening at a position that one might
intuitively call a "tail" position. So, in this case, what disqualifies
f from being in tail position? Can you give me an example of a call to
f that would be in tail position, so I can understand the difference?
Sorry if you've already provided such an example; I appreciate your
explanations, and I'm just trying to make sure I fully understand.
Mark will probably have a more precise answer for you, but let me offer
my understanding too. In general, in
( ... arbitrary code around ...
(f)
... )
the (f) call is in a tail position if _nothing_ else needs to be done,
to the return value(s) of (f), before returning from that block as a whole.
So, common examples of tail position are
(begin
...
(f))
and
(if <condition>
(f))
The case you mentioned, (list (f)), is probably the simplest example of
a non-tail position, because something very clearly does need to be done
to the return value of (f): it needs to be inserted into a newly
allocated list.
Regards - Neil