Draft #4 comments Peter McGoron (19 Jun 2026 17:36 UTC)
Draft #4 comments Peter McGoron (19 Jun 2026 17:39 UTC)
Draft #4 comments Peter McGoron (19 Jun 2026 17:50 UTC)
Re: Draft #4 comments Wolfgang Corcoran-Mathe (21 Jun 2026 17:20 UTC)
Re: Draft #4 comments Peter McGoron (21 Jun 2026 18:03 UTC)
Re: Draft #4 comments Wolfgang Corcoran-Mathe (21 Jun 2026 18:47 UTC)
Re: Draft #4 comments Wolfgang Corcoran-Mathe (22 Jun 2026 18:48 UTC)

Draft #4 comments Peter McGoron 19 Jun 2026 17:34 UTC

1. Some instances of "random-port" as a phrase should probably be
"random port".

2. Chacha is a deterministic RNG, so it might be better to move it to
the determinized section. `(srfi 271 randomized hwrng)` for the Linux
kernel's /dev/hwrng interface
<https://docs.kernel.org/admin-guide/hw_random.html> is be a better example.

3. In the description of `make-random-port`, I would explicitly note
that implementers may allow other objects to initialize random ports,
and that they should raise an initialization error if the object cannot
initialize a port.

4. I would still like to see the “trivial” random port that just outputs
a given bytevector cyclically. Such a port isn't possible to implement
in R7RS and can be used to seed all but the most pathological ports with
fixed high-entropy data.

5. I would add a code example to show the deterministic behavior of the
ports.

```scheme
(import (scheme base) (srfi 271 determinized)
         (prefix (srfi 271 randomized) r:))

(define port (make-random-port))

;; Explicit initialization using another port.
(let ((port2 (make-random-port (r:make-random-port))))
   (equal? (read-bytevector 100 port)
           (read-bytevector 100 port2))) ⇒ #f with a high probability

(define port-state (random-port-state port))

;; Initializing using the port state.
(let ((port2 (make-random-port port-state)))
   (equal? (read-bytevector 100 port)
           (read-bytevector 100 port2))) ⇒ #t

(random-port-state=? (random-port-state port)
                      (random-port-state port2)) ⇒ #t

;; Serialization.
(let ((output (open-output-string)))
   (write port-state output)
   (let* ((str (get-output-string output))
          (input (open-input-string str))
          (serialized-state (read input)))
     (random-port-state=? port-state serialized-state))) ⇒ #t
```

(If trivial ports are added this example should change to show how they
are used.)

-- Peter McGoron