all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#33731: 26.1; cl-make-random-state copying not working
@ 2018-12-13 21:12 Xu Chunyang
  0 siblings, 0 replies; only message in thread
From: Xu Chunyang @ 2018-12-13 21:12 UTC (permalink / raw)
  To: 33731

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





^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-12-13 21:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-13 21:12 bug#33731: 26.1; cl-make-random-state copying not working Xu Chunyang

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.