Subject: 26.1; cl-make-random-state copying not working

From: Xu Chunyang <[email-masked]>
Date: Fri, 14 Dec 2018 05:12:35 +0800

Hi,

I am reading (info "(cl) Random Numbers") on cl-make-random-state. I
expect the following returns two equal numbers, because s should be a
copy of cl--random-state thus two cl-random should use two equal
state.

(let ((s (cl-make-random-state)))
  (list (cl-random 10000)
        (cl-random 10000 s)))
;; => (6955 916)

If I didn't misunderstand this, I think it is because
cl-make-random-state uses copy-tree, however it doesn't work for
cl-structure at least in Emacs 26.1, it doesn't copy at all.

(eq (cl-make-random-state 123)
    (cl-make-random-state 123))
;; => nil

(let* ((s1 (cl-make-random-state 123))
       (s2 (cl-make-random-state s1)))
  (eq s1 s2))
;; => t