[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: parallel with no exprs
From: |
Mikael Djurfeldt |
Subject: |
Re: parallel with no exprs |
Date: |
Mon, 09 Jun 2003 10:35:50 +0200 |
User-agent: |
Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux) |
Kevin Ryde <address@hidden> writes:
> I tried using parallel with no expressions,
>
> (use-modules (ice-9 threads))
> (call-with-values
> (lambda ()
> (parallel))
> (lambda ()
> (display "hi\n")))
>
> but got
>
> ERROR: In procedure lambda:
> ERROR: bad body
>
> Is parallel allowed to be called with no expressions? It'd be pretty
> silly to write that deliberately, but perhaps it could arise from a
> simple-minded macro expansion or something.
>
> * threads.scm (parallel): For no forms, use `(values)' not `(begin)'.
>
> * tests/threads.test: New file, exercising "parallel".
>
>
> --- threads.scm.~1.21.~ 2003-04-28 07:51:19.000000000 +1000
> +++ threads.scm 2003-06-08 14:31:57.000000000 +1000
> @@ -182,7 +182,7 @@
> %thread-handler)))
>
> (define-macro (parallel . forms)
> - (cond ((null? forms) '(begin))
> + (cond ((null? forms) '(values))
> ((null? (cdr forms)) (car forms))
> (else
> (let ((vars (map (lambda (f)
Please don't apply this patch.
The original code is correct. The error instead lies in the use of
parallel. You'll find that for example
(use-modules (ice-9 threads))
(call-with-values
(lambda ()
(display "hello\n")
(parallel))
(lambda ()
(display "hi\n")))
will be accepted. (lambda () (parallel)) correctly yields an error
message since that is a lambda with no expressions in the body.
Best regards,
Mikael