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: continuation and multi-threading


Keisuke Nishida <kxn30@po.cwru.edu> writes:

> Craig Brozefsky <craig@red-bean.com> writes:
> 
> > > I guess I should learn from the existing works.  I'll read the book
> > > and try to write a real VM and a compiler.
> > 
> > Oh no, please continue writing your VM!
> > 
> > It may be a wonderful book, but writing your VM will teach you much
> > more than a book can.  Perhaps a mix of the two is in order 8)
> 
> Of course :)  But books will teach me more than what I can think of
> in three weeks :) (After three weeks, my vacation will be over.)

Keisuke, please don't be afraid of the continuations!

They are probably much easier to deal with than you expect now.

You have, because of the fun of it, started a very interesting
personal project.  It's in fact so interesting that it might become
the new VM for Guile.

But in taking this step from your own project to the VM for Guile,
it's natural that there are some additional thresholds to pass.

For example, in order to become the new VM for Guile, it's important
that it doesn't have limitations which prevents implementing full R5RS
Scheme.

I think you should continue doing just what you have been doing,
except that you could give continuations a couple of hours of thought,
only enough so that you know how to build in order to be able to
support them some times in the future.

Continuations really are quite simple.  In a way, what `call/cc' does
is that it makes a procedure (called "continuation") out of the
context of the call to `call/cc' so that you can invoke what is
supposed to happen after the `call/cc' at any time later:

...1
(call-with-current-continuation foo)
...2

=>

(foo (lambda (x) ...1 x ...2 (*)))
...2 (*)

(Except that exits at (*) are the same point.)

You can probably implement it simply by taking a copy of the stack,
and that implementation is OK for Guile.

But it's still important that you understand them (something which I
expect you to do within a couple of hours).

Here's a reference into Dorai Sitaram's excellent Scheme tutorial:

http://www.cs.rice.edu/~dorai/t-y-scheme/t-y-scheme-Z-H-15.html#%_sec_13.1

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