Skip to content

Commit df5e075

Browse files
Technologicatclaude
andcommitted
doc/macros.md: shift/reset mapping is approximate, note the gap
Adds the missing caveat to the delimited-continuation parenthetical: in Felleisen-style shift/reset, returning from shift's body without invoking the captured continuation makes that value the value of the whole reset; in unpythonic, returning from g without calling cc feeds the return value into cc automatically. The unpythonic behaviour is more in line with Python's "return continues after the call site" convention, which is more idiomatic in this setting, but it does mean the mapping isn't 1:1. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent f2e6c9c commit df5e075

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

doc/macros.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1285,7 +1285,7 @@ Hence, if porting some code that uses `call/cc` from Racket to Python, in the Py
12851285

12861286
Observe that while our outermost `call_cc` already somewhat acts like a prompt (in the sense of delimited continuations), we are currently missing the ability to set a prompt wherever (inside code that already uses `call_cc` somewhere) and make the continuation terminate there. So what we have right now is something between proper delimited continuations and classic whole-computation continuations - not really [co-values](http://okmij.org/ftp/continuations/undelimited.html), but not really delimited continuations, either.
12871287

1288-
(Mapping to delimited-continuation terminology: the body of the *enclosing* function is the implicit body of `reset` — that's what delimits `cc`. The `call_cc[]` site does the job of `shift` (capture the rest of the enclosing function body as `cc`), and the called function `g` plays the role of `shift`'s body — the code that runs with the captured continuation in hand.)
1288+
(Mapping to delimited-continuation terminology: the body of the *enclosing* function is the implicit body of `reset` — that's what delimits `cc`. The `call_cc[]` site does the job of `shift` (capture the rest of the enclosing function body as `cc`), and the called function `g` plays the role of `shift`'s body — the code that runs with the captured continuation in hand. The mapping is approximate: in Felleisen-style `shift`/`reset`, returning from `shift`'s body without invoking the captured continuation makes that value the value of the whole `reset`; in `unpythonic`, returning from `g` without calling `cc` feeds the return value into `cc` automatically, which is more in line with Python's "return continues after the call site" convention.)
12891289

12901290
For the closure topology that the `call_cc` machinery actually produces — and what `cc` and `pcc` are doing under the hood — see [Topology of continuations: how the wiring works](#topology-of-continuations-how-the-wiring-works) below.
12911291

0 commit comments

Comments
 (0)