JuliaLang/julia — pull request #8309 by rfourquet (2014-09-11 13:27:06+00:00)
Title: Rand range

This is essentially two changes:
1) the semi-public API to get a RandIntGen object generating random integers in `1:n` is via a call to `randintgen(n)`. This is to be able in particular to extend the mechanism to `BigInt` for which the existing type `RandIntGen` doesn't fit well (cf. https://github.com/JuliaLang/julia/pull/8255). In the process, `RandIntGen` was simplified by making the first element of the range equal to 1: this was only used with this value AFAICS, and this was duplicating indexing logic as noted by @ivarne (who found that this change should not break packages in METADATA.jl). It seems this was first implemented in commit ab97911by @lindahua: was there a use for the first element field `.a` that I overlooked?
2) allow `rand(r)` to work for any indexable `r`, not only with ranges (e.g. `rand(["head", "tail"])`. It is really the continuation of commit 48f27bc, and overlaps a bit with #6003. This change is so small that I think it is harmless, whatever is done wrt #6003.

ps: I think the random.jl tests are not very safe as the seed is set the same at each run. Could the content of `__init__` function from base/random.jl be made a public function named e.g. `srand()`, which could be used in the tests?