[#11439] comments needed for Random class — "NAKAMURA, Hiroshi" <nakahiro@...>

-----BEGIN PGP SIGNED MESSAGE-----

15 messages 2007/06/12

[#11450] Re: new method dispatch rule (matz' proposal) — David Flanagan <david@...>

This is a late response to the very long thread that started back in

17 messages 2007/06/13

[#11482] Ruby Changes Its Mind About Non-Word Characters — James Edward Gray II <james@...>

Does this look like a bug to anyone else?

10 messages 2007/06/16

[#11505] Question about the patchlevel release cycle — Sylvain Joyeux <sylvain.joyeux@...4x.org>

1.8.6 thread support was broken in bad ways. It stayed for three months

20 messages 2007/06/20
[#11512] Re: Question about the patchlevel release cycle — Urabe Shyouhei <shyouhei@...> 2007/06/20

Hi, I'm the 1.8.6 branch manager.

[#11543] Re: Apple reportedly to ship with ruby 1.8.6-p36 unless informed what to patch — James Edward Gray II <james@...>

On Jun 27, 2007, at 4:47 PM, Bill Kelly wrote:

10 messages 2007/06/27

Re: comments needed for Random class

From: TRANS <transfire@...>
Date: 2007-06-13 00:26:41 UTC
List: ruby-core #11442
On 6/12/07, NAKAMURA, Hiroshi <nakahiro@sarion.co.jp> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> 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.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.

Will it be core or standard? If we need to require 'random', then I
might suggest adding additional convenience methods. Attached is a
collection of such methods. Some can be especially useful, like
Array#shuffle.

T.

Attachments (1)

random.rb (10.9 KB, application/x-extension-rb)

In This Thread