This is the mail archive of the
guile@cygnus.com
mailing list for the Guile project.
Re: searching an explanation: call/cc and 'do' strangeness
- To: Gary Houston <ghouston@easynet.co.uk>
- Subject: Re: searching an explanation: call/cc and 'do' strangeness
- From: "Peder Chr. Norgaard" <pcn@tbit.dk>
- Date: Wed, 28 Apr 1999 10:08:33 +0200 (MET DST)
- cc: chl@tbit.dk, guile@cygnus.com
On 27 Apr 1999, Gary Houston wrote:
> | Thank you for your answer. Regrettably, we are not quite certain what the
> | lesson of your answer is.
> |
> | Do we have to avoid using the call/cc for all kind of coroutine-style
> | iterations in datastructures? Or is there a way to encapsulate the usage
> | of call/cc so that we can trust code outside the encapsulation to behave
> | predictably? (OK, I guess the behaviour we have observed *is*
> | predictable, somehow, but only within a global scope of the entire
> | program).
>
> Hmm, folk-law says that continuations can be used to simulate threads,
> but I've never seen it done.
That is exactly my position: I have this idea that it *should* be
possible but I can't figure out how to make it work.
(Except that my need is not threads, but co-routines. Guile have threads,
working fine for many purposes, thank you, but they are too heavyweight
for this kind of work. Shortly, I want to "use call/cc to capture the
part of the walking state that is on the stack"; if I can't get that to
work, my alternative is not to use threads, but to capture the state
explicitly - which means that I need to recode a piece of fine walking
code to avoid use of recursion).
> You can't pass the current continuation
> into scopeWalkDemo as a parameter, since the binding would be
> captured. Maybe passing it in a variable would be helpful:
<example>
Well, it seems to work in the example. I'll give it a try and see if it
scales to my application. Let me see if I understand you right: the idea
is to use a global variable for the continuation? And this will work
because call/cc don't capture global bindings?
Or is the difference that there is only one global binding, but a new
binding for each iteration of "do"?
best regards
--peder chr.
Peder Chr. Nørgaard System Developer, M. Sc.
Telebit Communications A/S tel: +45 86 28 81 77 - 49
Fabrikvej 11 fax: +45 86 28 81 86
DK-8260 Viby J Denmark e-mail: pcn@tbit.dk