On Sep 11, 2009, at 6:12 PM, John Cowan wrote:

> Aubrey Jaffer scripsit:
>
>> One of the important attributes of a seedable pseudo-random number
>> generator is that it allows a computation to be repeated by starting
>> with the same seed.  A program containing:
>>
>>  (expt (random 42) (random 42))
>>
>> will not be portable between R5RS or R6RS implementations because the
>> order of evaluation is unspecified.
>
> That's true, but it's a gross understatement.  If you write:
>
> (define s (make-random-state))
> (let loop ()
>  (reset-random-state! 3141592653)
>  (display (expt (random 42) (random 42)))
>  (newline)
>  (loop))
>
> this code need not print the same number every time through the loop!
> It's permissible to use a different order of argument evaluation on
> *every evaluation* of the same procedure call.

In R5RS two notes in 4.1.3 could be construed to mean that this is not  
the case, I believe:

Note:   In contrast to other dialects of Lisp, the order of evaluation  
is unspecified, and the operator expression and the operand  
expressions are always evaluated with the same evaluation rules.

Note:   Although the order of evaluation is otherwise unspecified, the  
effect of any concurrent evaluation of the operator and operand  
expressions is constrained to be consistent with some sequential order  
of evaluation. The order of evaluation may be chosen differently for  
each procedure call.

One can argue whether (display ...) applications in different  
iterations of the loop are the same or different. I do not think the  
sameness is defined anywhere in the Report.

R6RS repeats these two notes.

--andrew



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

Reply via email to