Discussion:
[Jscheme-user] elf/future.scm
Kyle R. Burton
2006-08-02 18:52:11 UTC
Permalink
The future code makes sense to me, but doesn't work.

The function touch is returning a list - which is the code that I
would have expected it to execute.

Touch looks like this:

(define (touch f)
(if (future? f)
`(let ((thread (%future-thread f)))
(if thread (.join thread))
(if (%future-exception f) (throw (%future-exception f))
(%future-value f)))
f))

I think the backquote just needs to be removed for this to be correct
(it works for me):

(define (touch f)
(if (future? f)
(let ((thread (%future-thread f)))
(if thread (.join thread))
(if (%future-exception f) (throw (%future-exception f))
(%future-value f)))
f))

When I do this it does what I expect. Is this something anyone else
has used? Am I not getting something about how it's supposed to be
used or works?



Thanks,

Kyle


This is the test I was trying to run:

(define (run-parallel . functions)
(map
touch
(map
(lambda (func)
(%make-future func))
functions)))

(run-parallel
(lambda () 3)
(lambda () 4))

;; => (3 4)

Loading...