in reply to Re: Random number generator
in thread Random number generator

That a really neat idea.

As \undef always returns the same value regardless of how many times you call it within a given script, that will effectively turn the module into a singleton. This has the very desirable side-effect of ensuring that the random sequence isn't messed by calling multiple instances. It neatly removes the need to serialise the access.


Examine what is said, not who speaks.
1) When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong.
2) The only way of discovering the limits of the possible is to venture a little way past them into the impossible
3) Any sufficiently advanced technology is indistinguishable from magic.
Arthur C. Clarke.

Replies are listed 'Best First'.
Re: Random number generator
by Abigail-II (Bishop) on Apr 01, 2003 at 09:43 UTC
    It also removes the only reason why you'd want to use an OO wrapper around random: the ability to subclass it, and have parts of the program use a different random function. If you turn it into a singleton, you might as well just use rand directly.

    Abigail

      No! Really?

      ;^)


      Examine what is said, not who speaks.
      1) When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong.
      2) The only way of discovering the limits of the possible is to venture a little way past them into the impossible
      3) Any sufficiently advanced technology is indistinguishable from magic.
      Arthur C. Clarke.