This is the mail archive of the guile@sources.redhat.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: How often are continuations created?


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]