emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: random doesn't feel very random


From: Simon Leinen
Subject: Re: random doesn't feel very random
Date: Mon, 27 Aug 2012 08:31:53 +0200

On Mon, Aug 27, 2012 at 2:50 AM, Stefan Monnier <address@hidden> wrote:
> Therefore the PRNG should be seeded once at start-up, from a good
> source of entropy.

IIRC Emacs fails to seed its PRNG at start (IOW it is seeded with
a constant), which is why many packages use (random t).

So I think the right thing to do now is to do seed it at startup, then
make (random t) a no-op.

We could consider adding a way to get the PRNG state and reset it later,
but since the PRNG state is Emacs-wide and Emacs is more like an OS than
like an application w.r.t its packages, such an interface would need to
allow several named PRNGs, so you'd call (random N <id>) to get the next
"random" number from <id>'s stream.

What about implementing the Common Lisp conventions for treating PRNG state, i.e. an optional state argument to RANDOM, and a variable *RANDOM-STATE*? 
Instead of (RANDOM T), people could say something like (SETQ *RANDOM-STATE* (MAKE-RANDOM-STATE T)) if they really want.
-- 
Simon.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]