Re: Simpler calling convention?
Marc Nieper-WiÃkirchen 05 May 2020 15:12 UTC
Am Di., 5. Mai 2020 um 17:01 Uhr schrieb John Cowan <xxxxxx@ccil.org>:
>
> I've simplified things by removing the optional *s* argument everywhere, adding a parameter `current-random-source` initialized to SRFI 27's `default-random-source`, and a trivial bit of syntax (with-random-source source proc arg ...) that directly replaces any call that would use an explicit *s* argument. That puts all the optionality at the right end in the usual way.
(1) Does changing the parameter CURRENT-RANDOM-SOURCE affect existing
generators of random data? I guess not. Is this specified?
(2) Isn't the syntax
(with-random-source source (proc arg ...))
more in line with the bulk of specified procedures than
(with-random-source source proc arg ...)
?
The latter has also two defects: When used in conjunction with, say,
APPLY, it looks even stranger: (with-random-source source apply proc
arg ...). The second defect is that while in the former syntax (proc
arg ...) can be any expression (even a special form), this is no more
true for the latter.
Thus I would propose the following definition:
(define-syntax with-random-source
(syntax-rules ()
((with-random-source source expr) (parameterize
((current-random-source source)) expr))))
Marc