[REBOL] [style] Feeling REBOLish (was: Notes on seeding 'random/seed)
From: reboler::programmer::net at: 22-Mar-2004 21:21
Good stuff, Gregg!
I like yours better with two exceptions...
randomize: func [
"Reseed the random number generator with 'now/precise."
/with seed [date! time! integer!] "Enter your own seed."
random/seed any [seed to-integer checksum/secure form now/precise]
It is more REBOLish to have an explicit refinement (just like 'random and 'random/seed),
is a definite improvement.
Replacing 'either with 'any is also an improvement.
Part of the whole problem with 'random/seed in the first place is that there was not
detail given to know the type of arguments accepted. I want to be specific about the
the implementation. The user should know _explicitly_ what the seed is when the user
help (and not just when the user goes to the source i.e. >>source randomize).
This info is often lacking in REBOL functions, especially natives.
>> help randomize
RANDOMIZE /with seed
Reseed the random number generator with 'now/precise.
RANDOMIZE is a function value.
seed -- Enter your own seed. (Type: date time integer)
.... versus ...
>> help random
RANDOM value /seed /secure /only
Returns a random value of the same datatype.
RANDOM is an action value.
value -- Maximum value of result (Type: any)
/seed -- Restart or randomize ;<<!!! NO INFORMATION GIVEN!
/secure -- Returns a cryptographically secure random number.
/only -- Return single value from series.
The user should also be able to enter their _own_ seed without any processing by the
itself. Thus the user needs to know what data types are accepted.
These changes tell the user all he needs to know about using 'randomize.
Just my $0.02.
Gregg, thanks for your time and interest. Amazing how many ways to skin the cat.
Follow-up: Do you think that I should send REBOL feedback on the fact that 'random/seed
not use sub-second precision? IMHO, I think this should be considered a bug in 'random.
Sign-up for Ads Free at Mail.com