This is the mail archive of the
guile@sources.redhat.com
mailing list for the Guile project.
Re: How often are continuations created?
- To: guile at sourceware dot cygnus dot com
- Subject: Re: How often are continuations created?
- From: Radey Shouman <Radey_Shouman at splashtech dot com>
- Date: 12 Aug 2000 21:47:37 -0400
Mikael Djurfeldt <mdj@mdj.nada.kth.se> writes:
> Mikael Djurfeldt <mdj@mdj.nada.kth.se> writes:
[ ... ]
> Here's the Guile do code:
[ ... ]
> env = EXTEND_ENV (SCM_CAR (SCM_CAR (env)), t.arg1, SCM_CDR (env));
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> The problem is here: Guile creates a *new* frame instead of mutating
> the old, so call/cc will look at the fresh version of the first frame
> instead of the *mutated* version of the fresh form.
> }
> x = SCM_CDR (proc);
> if (SCM_NULLP (x))
> RETURN (SCM_UNSPECIFIED);
> PREP_APPLY (SCM_UNDEFINED, SCM_EOL);
> goto begin;
>
> This can be fixed by mutating the frame when updating it.
Guile's behavior is mandated by R5RS, see the section "Iteration"
under "Derived Expression Types". Each DO iteration must create new
bindings, not mutate existing bindings.
See also the R5RS DEFINE-SYNTAX exemplary definition of DO in the
"Formal Syntax and Semantics" section -- there DO expands to a LETREC
binding a function which is tail-called for each iteration.