Julia: Rename `srand` to `Random.seed`

Created on 22 Jun 2018  路  10Comments  路  Source: JuliaLang/julia

I frequently need to look this up and it seems to be against the naming convention of spelling things out.
Other scientific languages do not use that syntax either:

  • R had srand but its deprecated, now uses set.seed()
  • MATLAB uses rng(seed)
  • Python uses random.seed()

While C actually uses srand, i think we want to improve upon C-Syntax?

Edit: There has been some short discussion about this in 2014

RNG deprecation

Most helpful comment

Unexported Random.seed?

All 10 comments

I would also propose reseed!

I prefer something with rand in it. So seedrand.

Yes, seedrand seems like a pretty good name.

Unexported Random.seed?

Since we do have randjump, why not go with randseed instead? Other option is to perhaps make them both unexported.

Since we do have randjump, why not go with randseed instead?

I like the increased consistency (but see also bitrand), although it may sound to some like randseed would return a random seed, in the same way we have randperm and randstring producing random permutations and strings.

That is a good point.

So the choice is between seedrand and unexported Random.seed.
I like both, but I think Random.seed may be the better option:

  • it's reasonably short
  • seeding an RNG may not be considered beginners usage, so discoverability should not be a problem.
  • i like how Random stands out in the code for readability
  • it's the same in Python

If anybody wants this in 0.7, it needs to be done ASAP.

Random.seed can happen if someone makes a PR in the next day, but this is not a release blocker.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TotalVerb picture TotalVerb  路  3Comments

manor picture manor  路  3Comments

sbromberger picture sbromberger  路  3Comments

ararslan picture ararslan  路  3Comments

omus picture omus  路  3Comments