Email list hosting service & mailing list manager

comments on generators Per Bothner (10 Jan 2016 03:26 UTC)
Re: comments on generators Shiro Kawai (10 Jan 2016 03:54 UTC)
Re: comments on generators Per Bothner (11 Jan 2016 06:29 UTC)
Re: comments on generators John Cowan (11 Jan 2016 01:38 UTC)

comments on generators Per Bothner 10 Jan 2016 03:26 UTC

Two notes and a meta-note.  First the meta-note:

Overall, this seems a useful and reasonable SRFI.  However,
I reserve judgment about whether it belongs in R7RS-large.

make-bits-generator n
It is worth noting that the last element if (> n 0) is #t,
while the last element if (< n -2) is #f.
Unfortunately, both (= n 0) and (= n -1) return the empty generator.
So make-bits-generator is *almost* invertible.
The specification could mention one way to extend the bits list
with one more bit to represent the inifinite rest:
   (gappend (make-bits-generator n) (generator (>= n 0)))
(ITOH since I don't have a use-case for make-bits-generator,
or for inverting it, I don't know if this is an issue.)

gcombine proc seed gen gen2 …
IMO It would be more natural for proc to not take a seed.
Instead we should standardize gmap:
(gmap proc gen1 gen2 ...) where proc is called as (proc v1 v2 ...)
I note  gcombine doesn't add any functionality beyond gmap:
(define (gcombine proc seed . gens)
    (apply gmap (lambda vs (apply proc (append vs (list seed))) gens)))

or using Kawa's more readable splice syntax:

(define (gcombine proc seed . gens)
   (gmap (lambda vs (proc @vs seed)) @gens))

--
	--Per Bothner
xxxxxx@bothner.com   http://per.bothner.com/