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: Stefan Monnier
Subject: Re: random doesn't feel very random
Date: Sun, 26 Aug 2012 20:50:22 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux)

> Therefore the PRNG should be seeded once at start-up, from a good
> source of entropy.

I tend to agree.

> Given the widespread use of (random t) it should probably be made a
> no-op and a separate API to provide a local state for application that
> wish to control it for whatever reason should be made available.

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.


        Stefan



reply via email to

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