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: Fri, 31 Aug 2012 11:06:45 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux)

>> > It is a feature that, if you don't call (random t), `random' returns
>> > a predictable sequence.  That is good for debugging.
>> I wonder how often this has been useful.
> ??? A pseudo-random sequence is always deterministic, that's what the
> "pseudo" part is about.  I'm sure you already know that.

Yes, obviously I know that.  So you've misunderstood what I said.
I'm saying that I highly doubt that the fact that `random' always
returns the exact same stream unless you explicitly call (random t)
has been often useful (and used) for debugging in practice.

>> many packages call (random t) at various times
> Those packages have a bug that needs to be fixed.

My point was that those bugs make the above "feature" more difficult to
use, making it that much more doubtful that it has ever been useful.

As for whether they're bugs or not: I tend to agree that they're bugs,
but since currently our PRNG is not automatically seeded, those packages
that need their `random' to vary (IOW basically every package that
uses random) have no other choice but to call (random t) explicitly at
various times.
So to fix those bugs, we have to:
- change Emacs's initialization so that it seeds its PRNG.
- eliminate most/all calls to (random t), which is best done by changing
  `random' to do nothing when called with argument t (after all,
  re-seeding wouldn't make it less predictable anyway).


        Stefan



reply via email to

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