[erlang-questions] process dictionary, anyone?

Luke Gorrie luke.gorrie@REDACTED
Sat Apr 28 20:52:12 CEST 2007


Per Hedeland <per@REDACTED> writes:

>>Most people calling random:uniform/1 will want a randomish number,
>
> Did you take a survey?:-)

I have grepped our 700KLOC source tree for calls to the random module.

I see 75 calls to random:uniform/1:

- None are obviously depending on repeatability. Maybe they do, but I
  doubt it. If I were writing a simulation that depended on
  repeatability I would explicitly call random:seed0() to make that
  intention explicit.

- I see three calls to random:uniform/0. They are all in process
  'init' functions so none actually has any effect (the process gets
  the default constant seed with or without the call). I tend to think
  these are all bugs and the intention was to seed from something
  unpredictable but I can't prove it.

- Several that are not seeded are obviously in error (mostly code
  written by me, but that's where the real intention is clearest)

- 25 are seeded by now() in code written by well-respected Erlang
  programmers who are friends of yours and have backgrounds in
  developing security products :-)

- None are seeded by anything other than now()

In fact it's timely that I checked this. We have just patched Yaws to
stop reusing request-handler processes and it looks like this will
cause some calls to random:uniform in appmod code to do the wrong thing.

Perhaps the random module interface can be justified in terms of unix
arcana but I counter-cite the better interfaces of Perl, Python, and
even Java that all try to auto-seed the random number generator as
best they can (urandom, current time, etc) unless you ask otherwise.

Why optimize the interface for statisticians writing simulations when
it's loonies writing telecom code late at night who actually use it? :-)





More information about the erlang-questions mailing list