``` Subject: Re: Constants and DEFCONSTANT From: rpw3@rigden.engr.sgi.com (Rob Warnock) Date: 1999/04/04 Newsgroups: comp.lang.lisp Message-ID: <7e6qip\$k81b@fido.engr.sgi.com> ```
```Kent M Pitman  <pitman@world.std.com> wrote:
+---------------
| > Yes, there's some ambiguity in `reference.'
|
| Incidentally, this ambiguity hit the Scheme community when there was
| a question of whether:
|  (let ((x (+ y 3)))
|    x)
| has (+ y 3) in a "tail recursive" position.  I think that's the funny
| case, anyway.
+---------------

Perhaps you are thinking of some other funny case? This one seems pretty
clear (even without resorting to R5RS). Since (even in R4RS) "let" is a
"derived expression", its defining semantics are given in terms of a
procedure call of its body, i.e., translating your example:

((lambda (x) x) (+ y 3))

Now that being the case, and given that Scheme is a call-by-value
variant of the lambda calculus, if I understand these things correctly
the "(+ y 3)" is *not* in a tail position, since it must be evaluated
*before* the call to the lambda.

The lambda itself is not in a tail position, either, for the
same reasons. But the *body* of the lambda ("x", in this case) is...

Hmmm... I see here that R5RS *allows* the beta-reduction to "(+ y 3)"
[which would convert it to a tail call of "+"], in section "3.5 Proper
Tail Recursion" [just after the example Darius(?) quoted which contained
a (let ((x (h))) x) as one branch of an "if"], where it says:

Note: Implementations are allowed, but not required, to recognize
that some non-tail calls, such as the call to "h" above can be
evaluated as though they were tail calls. In the example above,
the "let" expression could be compiled as a tail call to "h".

So it's only "in a tail position" if your compiler is smart enough to
*prove* that making it so won't break the semantics...

-Rob

-----
Rob Warnock, 8L-855		rpw3@sgi.com
Applied Networking		http://reality.sgi.com/rpw3/
Silicon Graphics, Inc.		Phone: 650-933-1673
2011 N. Shoreline Blvd.		FAX: 650-964-0811
Mountain View, CA  94043	PP-ASEL-IA

```