[gambit-list] call/cc behavior in gambit-c vs. plt-scheme
mflatt at cs.utah.edu
Wed Jun 11 10:42:56 EDT 2008
At Wed, 11 Jun 2008 08:06:24 -0400, Marc Feeley wrote:
> I'm actually surprised that PLT does not do the same. Most probably
> PLT's "load" is modeled on the REPL (i.e. it is a read-eval-print loop
> which simply takes its input from a file). So the continuation stored
> in coco is really:
> (lambda (result)
> (display "again")
> (display "end")
> But when (next-iteration-of-the-load-repl) is called, it will read end-
> of-file and thus exit load's read-eval-print loop.
> I think Gambit's model is cleaner, as it allows to have the same
> semantics for load whether the file being loaded is source code or
> compiled code.
For what it's worth, here's what PLT Scheme actually does:
* Every top-level form is wrapped with a prompt.
* `begin' at the top level splices. Consequently, each sub-form within
a top-level `begin' is also wrapped with a prompt.
That's why `(coco 13)' after the `load' produces 13, instead of an
error about a closed file.
[ If anyone wonders what I mean by "prompt", see
It's true that `load' in PLT Scheme reads and evaluates forms from a
file one-by-one, but still with prompts. That can be consistent with
compiling the forms one-by-one to produce a file whose compiled
fragments are evaluated one-by-one. In particular, the prompts around
sub-forms in a top-level `begin' help keep everything consistent
(without having say, for example, that `begin' only sort of "splices"
into the top level). Concretely, try compiling Cristian's example with
`mzc --zo' and `load' the resulting ".zo" file.
Of course, `load' in neither Gambit nor PLT Scheme really makes
evaluation from source consistent with evaluation of compiled code ---
not when macros get involved. Given how the Scheme top-level is
hopeless in this respect, PLT Scheme leaves most problems of
compiled-vs-source consistency to the module system, and we see `load'
as a tool similar to REPL evaluation. From that perspective, prompts
play a role in making `load' and REPL evaluation more consistent with
More information about the Gambit-list