List Info

Thread: Re: comments needed for Random class




Re: comments needed for Random class
country flaguser name
United States
2007-06-13 13:52:10
"NAKAMURA, Hiroshi" <nakahirosarion.co.jp> writes:

> Hi all,
>
> # Especially to Technorama Ltd.
>
> We're discussing about introducing Random class for
PRNG on ruby-dev ML.
>
>  * current rand and srand changes global state.  it
should be the
>    source of a security problem sooner or later in this
"framework" era.
>    (I claimed)
>  * Mats agreed to introduce a class for PRNG based on
current Mersenne
>    Twister implementation.  class name is
"Random".
>  * no plan to introduce another PRNG based on other
PRNG algorithm.
>    MT is the only PRNG engine for "Random".
>  * we're now discussing what methods "Random"
should have.
>
> Here's my proposal (no agreement for now);
>
> Random#integer(max)
> Ramdom#bytes(size)
> Random#float         # same as Random#rand(0).  not
needed?
> Random#rand(max = 0)
> Random#srand(seed = nil)
> Random#seed=(seed = nil) # same as Random#srand(seed)

Random#seed          # returns the most recently used seed
Random#random_seed   # exposes the existing C random_seed()

Steve

> Random.rand(max = 0) # calls Random#rand(max) of the
singleton Random
>                      # object which is initialized with
the current
>                      # srand().
>
> rand(max = nil)      # calls Random.rand(max)
> srand()              # srand() now takes no argument
for 1.9.
>
> Comments needed.
>
> Regards,
> // NaHi



[1]

about | contact  Other archives ( Real Estate discussion Medical topics )