# Is this explanation about tail position clear and it's just me?

**URL:** <https://racket.discourse.group/t/is-this-explanation-about-tail-position-clear-and-its-just-me/4405>\
**Category:** Questions & Answers\
**Created:** [September 29, 2026, 10:06am UTC](https://racket.discourse.group/t/is-this-explanation-about-tail-position-clear-and-its-just-me/4405 "2026-09-29T10:06:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gbellinoz](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/gbellinoz/32/2738_2.png) [@gbellinoz](https://racket.discourse.group/u/gbellinoz)\
**Post date:** [September 29, 2026, 10:06am UTC](https://racket.discourse.group/t/is-this-explanation-about-tail-position-clear-and-its-just-me/4405/1 "2026-09-29T10:06:13Z")

</div>

I'm pretty sure I understand tail position, but I want to understand the formal definition in The Racket Reference.

Does [the definition](https://docs.racket-lang.org/reference/eval-model.html#(part._.Tail_.Position)) seem pretty clear to you? Would you re-write any of the statements in that section for clarity?

To tip my cards, the first line gets me:

> An expression _expr1_ is in _tail position_ with respect to an enclosing expression _expr2_ if, whenever _expr1_ becomes a redex, its [continuation](https://docs.racket-lang.org/reference/eval-model.html#%28tech._continuation%29) is the same as was the enclosing _expr2_’s [continuation](https://docs.racket-lang.org/reference/eval-model.html#%28tech._continuation%29).

The only way I can see _expr1_'s continuation being the same as _expr2_'s is if the continuation for both was `[]`. Or, as the first example says "just C".

I also think it's confusing to bring in C as "some continuation C" (unspecified). In the examples, both _expr1_ and _expr2_ are shown/considered (ie. not "C"). Why do we need to think about the next level up enclosing continuation? The stuff in the brackets will never depend on it, right?

(Yes I asked Claude, but what came back seemed like gobbledegook word salad)

---

<div class="post-metadata">

**Author:** ![ryanc](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/ryanc/32/71_2.png) [@ryanc](https://racket.discourse.group/u/ryanc)\
**Post date:** [September 29, 2026, 12:21pm UTC](https://racket.discourse.group/t/is-this-explanation-about-tail-position-clear-and-its-just-me/4405/2 "2026-09-29T12:21:24Z")

</div>

Here's a simple example where the continuation of the sub-expression (when it becomes a redex) is the same as of the enclosing expression:

```scheme
   (add1 (if (zero? 0) (+ 1 1) 3))
-> (add1 (if #t (+ 1 1) 3))
-> (add1 (+ 1 1))

```

When `(if (zero? 0) (+ 1 1) 3)` _begins evaluation_, its continuation is `(add1 [])`. When its sub-expression `(+ 1 1)` becomes a redex, its continuation is also `(add1 [])`.

_(Edit: After thinking some more, I believe that the definition's use of "becomes a redex" is incorrect. It should be "begins evaluation" or "occurs in an evaluation context". Whether an expression is in tail position should not depend on whether that expression is a redex, or ever reduces to a redex. For example, I would like to be able to say that `1` and `(add1 (error))` occur in tail position, but neither expression is a redex nor reduces to one. There's also the issue that, for example, `(+ 1 1)` is vacuously in tail position with respect to `(+ (error) (+ 1 1))`.)_

* * *

To your next question: no, the stuff in the brackets might in fact depend on the continuation. For example:

```scheme
(let ([f (lambda () (+ 1 1))])
  (if (continuation-prompt-available? my-prompt)
      (void (f))
      (f)))

```

Is `(+ 1 1)` in tail position with respect to the whole expression? If the expression is evaluated in the empty context, then `(+ 1 1)` is also evaluated in the empty context. But if the expression is evaluated in the context created by `(call-with-continuation-prompt (lambda () []) my-prompt)`, then `(+ 1 1)` is not evaluated in the same context; it has an extra `(void [])` frame.

Continuation marks and control operators like `call/cc` provide more reasons that the continuation might matter.

---

<div class="post-metadata">

**Author:** ![benknoble](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/benknoble/32/16_2.png) [@benknoble](https://racket.discourse.group/u/benknoble)\
**Post date:** [September 29, 2026, 12:34pm UTC](https://racket.discourse.group/t/is-this-explanation-about-tail-position-clear-and-its-just-me/4405/3 "2026-09-29T12:34:52Z")

</div>

> I'm pretty sure I understand tail position, but I want to understand the formal definition in The Racket Reference.
> 
> Does the definition seem pretty clear to you? Would you re-write any of the statements in that section for clarity?
> 
> To tip my cards, the first line gets me:
> 
> An expression expr1 is in tail position with respect to an enclosing expression expr2 if, whenever expr1 becomes a redex, its continuation is the same as was the enclosing expr2’s continuation.

There are four components here: expr1, expr2, expr1's continuation  
(when it becomes a redex) and expr2's continuation (which all the  
examples call "C" in the notation).

> I also think it's confusing to bring in C as "some continuation C" (unspecified). In the examples, both expr1 and expr2 are shown/considered (ie. not "C"). Why do we need to think about the next level up enclosing continuation?

Thus we have to think about some (in these examples, unspecified)  
continuation one level up; it's one of the 4 components.

> The stuff in the brackets will never depend on it, right?

Well, I'm sure there's an argument to be made involving one of the  
continuation primitives which intertwines things.

> The only way I can see expr1's continuation being the same as expr2's is if the continuation for both was . Or, as the first example says "just C".

The example with "if" if the docs uses an arbitrary continuation; it  
need not be empty.

(Ryan's message came in while I was typing this, and I think it's a  
bit more concrete, so I'll leave the examples to them! I think it's  
still worth being explicit about the connection between the components  
of the definition and the need to thus label the enclosing expr2's  
continuation.)
