David Kastrup <d...@gnu.org> writes:
> I assume that the above list could contain more than a single call of
> (suspend).

Yes, of course.

>> For example, (%% list 1 2 3 (begin (suspend) 4) 5) expands to:
>>
>>   (call-with-values
>>       (lambda () (parallel (suspendable list)
>>                            (suspendable 1)
>>                            (suspendable 2)
>>                            (suspendable 3)
>>                            (suspendable (begin (suspend) 4))
>>                            (suspendable 5)))
>>     (lambda (proc . args)
>>       (apply (final-values proc) args)))
>>
>> Is this what you're looking for, or something close to it?
>
> Not really.  The above uses "parallel", and if I remember correctly,
> this implies multi-threaded execution and true asynchronicity
> (preemptive scheduling).  I was rather thinking about avoiding the
> overhead and work things off serially but without stopping if one part
> runs into suspension, but rather commencing with another part of the
> expression until every branch has run into suspension.  Effectively
> multithreading without preemption and the associated costs.

That's easy enough.  Simply changing `parallel' to `values' in the
definition of %% would be enough to get rid of the parallelism, but
here's a simpler definition for a non-parallel %%:

  (define-syntax-rule (%% op operand ...)
    (op (suspendable operand) ...))

With this one change, I think this now does what you are describing.

      Mark

Reply via email to