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

Question about lexical closures and message passing concurrency.



	I was reading about Erlang the other day, and so I was thinking about 
languages with only Message Passing concurrency. Erlang is 
single-assignment, so a lexical closure like this random number generator 
would not be possible because of the "set!":
         (random-maker (let* ((next-random
                               (lambda (x) (modulo (+ (* x 4096) 150889) 
714025))))
                         (lambda (initial-seed)
                           (let ((seed initial-seed))
                             (lambda args
                               (set! seed (next-random seed))
                               seed)))))

But if you didn't want to do single-assignment, whats the proper way to 
support a lexical closure being passed around multiple threads which cannot 
share memory. I mean, the naive thing to me seemed to be to copy the entire 
closure and pack it off to thread, but that seemed to naive to be correct, 
and certainly could result in rather large amounts of data being copied.
	I hope this is not a dumb question, and I hope my usage of terminology is 
correct. I'm just a graduate student so I'm still learning :).

						Matt Estes