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

parallel argument evaluation



	... It seems unreasonable to insist that all Scheme programmers must 
	follow Multilisp style standards if their code is to be portable, and 
	doubly so when we aren't providing any synchronization constructs.

    I'm inclined to agree, but we're already doing that to some extent, by
    requiring that portable code not depend on order-of-sequential-evaluation 
    of arguments.  So you see it's really a matter of degree.

I would agree; on the other hand, the degree is quite significant.
Suppose you define a random-number-generator rand by

	(define rand
	  (let ((seed (initial-random-seed)))
	    (lambda ()
	      (set! seed (random-update seed))
	      seed)))

and then you write programs like

	(+ (rand) (rand))

This works fine for any sequential argument evaluation order, but the
updating of the random number seed is not safe if multiple calls to rand
are active concurrently.  Lots of other cases of procedure arguments
whose evaluation involves side effects (but not in a way that breaks if
a different sequential evaluation order is used) are analogous.

If you're writing genuinely parallel code (as in Multilisp or Qlisp)
then you probably want to strongly encourage people to change their
random number generators so that it is safe for multiple random number
generations to be active concurrently.  But I suspect that the Scheme
community would balk at having to do this in order to make their
programs "truly" portable.				-Bert Halstead