-
Notifications
You must be signed in to change notification settings - Fork 432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CHANGE: rename Rng methods random, gen_* #1503
Comments
I am in favor of using the |
I agree, except that |
It's just 3 letters longer than |
I agree. Any other thoughts @vks, @oconnor663? |
I prefer using Maybe this understanding issue could be addressed with a larger poll. |
This is just bikeshedding, but I think There is precedence for just using the type names, this is what |
Then it sounds like the consensus may be:
I think your suggestions are too long!
|
How about |
I haven't had occasion to use if rng.chance(0.5) {
println!("winner!");
} |
Adds random_iter, random_range, random_bool, random_ratio, fill. See also #989, #1503. Co-authored-by: Diggory Hardy <[email protected]>
#989 discusses the addition of methods like
rand::range
, which leads back toRng::gen_range
.#1438 and #1500 already renamed
gen
→random
andgen_iter
→random_iter
.Since we no longer have
Rng::gen
, should we renamegen_range
,gen_bool
andgen_ratio
?Aim: make method/function names consistent, memorable and easily comprehensible.
Proposals
Old (v0.8)
Before
gen
was deprecated, we had:Status quo
If we make no further changes, we have the following
Rng
methods:gen_bool → p; drop gen prefix
We could just:
And yes, it appears that we can use
bool
as a method name (it's a primitive type, not a keyword).gen_bool → p; drop gen prefix
This is the most concise change:
Is it clear enough that
rng.p(p)
is generating a random variate whereP(X = true) = p
?Some weird variations on this:
gen_ → random_
A straightforward replacement gives us:
This seems fine, if a bit long.
random → next
We already have
RngCore::next_u32
etc., so we could renamerandom
(what wasgen
) tonext
:Caveat 1: this no longer matches
rand::random
(which we probably don't want to rename torand::next
).Caveat 2:
rng.next_iter()
is a weird name; we can't really userng.iter()
however since it generates an iterator overStandard
samples, not an abstract iterator over the RNG.The text was updated successfully, but these errors were encountered: