On Thu, 10 Sep 2009 10:45:43 -0400, Vitaly Magerya <[email protected]>  
wrote:

> Aubrey Jaffer wrote:
>> An example of an exception
>> is the use of a pseudo-random-number-generator having shared state:
>>
>> (require 'random)
>> (+ (random 99) (random 99))
>>
>> The concurrency-safe version could be written:
>>
>> (require 'random)
>> (let* ((rnd1 (random 99))
>>        (rnd2 (random 99)))
>>    (+ rnd1 rnd2))

There is no problem with parallelizing (+ (random ---) (random ---))  
assuming that RANDOM is thread safe, which it is perfectly natural to  
assume that it is in a parallel Scheme system. We don't need to do this  
transformation. We may not be able to guarantee which of the RANDOM calls  
occurs first, but that doesn't matter, since either way we will get some  
result that is equivalent to some sequential ordering of execution. I  
don't see the problem.

> Isn't this a rather major penalty for using side-effecting code? I just
> wonder how much of a problem this may be in practice.

Yes, this is high, and I do not think that this is necessary.

        Aaron W. Hsu

-- 
Of all tyrannies, a tyranny sincerely exercised for the good of its  
victims may be the most oppressive. -- C. S. Lewis

_______________________________________________
r6rs-discuss mailing list
[email protected]
http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss

Reply via email to