[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Re: to serialize/deserialize closures; and multithreading

From: Faraz Shahbazker
Subject: Re: Re: to serialize/deserialize closures; and multithreading
Date: 26 Mar 2004 20:02:51 -0000

        The problem with Kali and other distributed Scheme
implementations (and there are quite a few) is that most of
them are built around the imperative style of parallel
computation -- result: things get ugly quickly for complex
programs. You could end-up writing C-like programs in

        IMHO the ideal system would be built around pure
functional style (using MultiLisp type parallel annotations
like future/touch/pcall). This category is also known as
para-functional languages. It has been explored reasonably in
ML/Haskell, but little work of this nature has been done in
Scheme/Lisp so far.....

> Autsch, that does get rather expensive when closures/continuation
> are used (something that does happen occasionally in functional
> programming ;-)

        That I accept. It can be speeded up by building the
transformation into the compiler, something which is not possible
with guile - bigloo perhaps would be a better choice for such work.
But it is difficult to leave guile for 2 reasons :

1. it's got the "GNU" in it's name
2. SCM API is too good - absolutely love it. I don't think anyone
can provide a better extensibility for Scheme than what we have here.

As an aside : for functional purists like me, we should built
future/touch constructs into guile - they are a lot of fun.
Try out these prototypes =>
(Note : these are not actually correct - the simple semantics fail
in the presence of mutations/continuations. A proper implementation
would have to be done in C using Guile-internals)

        It basically works like delay/force except that any-thing
that is "future"d returns a place-holder immediately and starts
concurrent computation. When the value is required, you "touch"
the place-holder, causing a block until the computation completes.

(defmacro future (expr)
  `(let ((ans (cons "#<future>" (cons #f #f))))
     (set-car! (cdr ans)
                (set-cdr! (cdr ans) ((lambda () ,expr)))))

(defmacro touch (future-val)
     (join-thread (car (cdr ,future-val)))
     (cdr (cdr ,future-val))))

- faraz 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]