[#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: "NAKAMURA, Hiroshi" <nakahiro@...>
Date: 2007-06-16 02:02:36 UTC
List: ruby-core #11471
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

Thanks all for your comments.

1. Random#rand(range): it is proposed in ruby-dev, too.  I dropped it
from my previous proposal because begin/last of a Range can be a float
number.  I couldn't imagine what Random#range(Range.new(1.1, 3.1))
should return.

2. Random#seed: should be added.

3. Random#random_seed: same as Random#srand(0), right?

4. Random#boolean, Random#gaussian: let's discuss to add it in the
future when an user claims to add.  I know gga claims to add this so
we'll be able see a patch soon after once Random class introduced.  :-)
Which do you plan to add GaussianRandom or Random#gaussian?

5. saved_seed: a Random should have marshal_dump and marshal_load.
 isn't it enough?

6. Array, Hash and String methods: let's discuss to add it later. :-)

	/	/	/

As the result, a proposal is as follows for now:

Random#integer(max_plus_one_or_range)
Ramdom#bytes(size)
Random#float                # same as Random#rand(0)
Random#rand(max_plus_one_or_range = 0)
                            # only allows range with Integer begin/last
                            # ArgumentError otherwise
Random#srand(seed = nil)
Random#random_seed          # same as Random#srand(0)
Random#seed=(seed = nil)    # same as Random#srand(seed)
Random#seed                 # returns the most recently used seed

Random.rand(arg = 0)        # calls Random#rand(arg) of the singleton
                            # Random object which is initialized with
                            # the current srand()

rand(arg = 0)               # calls Random.rand(arg)
srand()                     # srand() now takes no argument for 1.9

Please allow me if I slipped a comment and let me know it.

Regards,
// NaHi

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (Cygwin)

iQEVAwUBRnNEoR9L2jg5EEGlAQJgzQgAg7e7zaABr58XOoMTUwa5/dcxlPRr6j7Z
fNXqAqKrSNbFow3mWJnUsro2hbZ41mlc6M/Cl2ko7ClzQl7D/iHhkT+srdKTtH0X
qwLyhkxrftVlm+rGoCr8HXH5Tyr97xZMs0y+sI+KZH7agN5YeGiGjMBnDsUYdecu
1eE2LTDdrPLtPAgjD0YXU43rsrcZPuMXzu/0XJsiYRi0aXoPdUrYkLILogbRDHOm
2Gy2/t38T4l0NarD87WbuBrJXYZj+l6wXgKl8ILhGfsa8sHF3mqy0aj1WX8m15y5
I0mdREyJxVLDo6cXc1M4k3tRanbOT1qo7bpNRHQBlbT0cphMrUvSuw==
=7UPQ
-----END PGP SIGNATURE-----

In This Thread