On Tue, 27 Oct 2009 15:05:27 -0400 (EDT)
Aubrey Jaffer <a...@alum.mit.edu> wrote:

> I have expanded and formalized the Implicitly-Concurrent-Scheme idea
> discussed here last month (under the name Implicit-parallel-Scheme):
> 
>   http://voluntocracy.blogspot.com/2009/10/implicit-concurrency.html
> 
> _______________________________________________
> r6rs-discuss mailing list
> r6rs-discuss@lists.r6rs.org
> http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss



This part scares me:

> This expression is portably-repeatable but not concurrently-repeatable
> because it would return twice:
> 
> (call-with-current-continuation
>  (lambda (return)
>    (/ (return 0) (return 0))))

It looks to me like ICS permits that expression to either fork or not
fork the thread it is called in, depending on:

- the capabilities of the implementation,

- whether or not the implementation decides that the arguments of /
  should be evaluated in parallel,

- how the implementation is configured, and

- possibly other factors (e.g. phase of the moon).

This lack of specification will make exception handling far more
difficult in ICS, and break backward compatibility.  Consider this
expression:

(+ (/ 1 0) (/ 1 0))

This is permitted to throw an exception in each of two threads.  If
(assuming the system uses R6RS exceptions) the exceptions are
continuable, and the handler returns to its continuation in both cases,
the expression will return once.  However, what if the exception
handler wants to end the computation?  In current code, an exception
handler can just call a captured continuation.  To run on an ICS
system that forks threads at will, an exception handler would need to
atomically call an escape continuation and replace it with a
thread-ending null continuation.  R6RS does not provide *any* atomic
operations, and even if there were, most existing Scheme programs would
not use an atomic operation for this purpose.



I like the idea of ICS, but I don't see how it can be useful while
still permitting implementors to use the current Scheme
argument-evaluation semantics. An implementation of the current Scheme
semantics would linearize an expression (f (g x) (h y)) into something
like:

(let ((g-x (g x))
      (h-y (h y)))
  (f g-x h-y))

An implementation of ICS is permitted to produce either the above code
or something like:

(let ((g-x-thunk (lambda () (g x)))
      (h-y-thunk (lambda () (h y))))
  (let ((g-x-thread (start-thread g-x-thunk))
        (h-y-thread (start-thread h-y-thunk)))
    (let ((g-x (wait-for-thread-and-retrieve-result g-x-thread))
          (h-y (wait-for-thread-and-retrieve-result h-y-thread)))
      (f g-x h-y))))

These two behaviors are very different, and a language specification
should not allow an implementation to choose between them at will.

Robert Ransom

_______________________________________________
r6rs-discuss mailing list
r6rs-discuss@lists.r6rs.org
http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss

Reply via email to