[erlang-questions] Erlang 20 and crypto:rand_uniform/2

Raimo Niskanen raimo+erlang-questions@REDACTED
Wed May 17 09:51:22 CEST 2017

On Wed, May 17, 2017 at 12:16:32AM -0700, Richard Bowker wrote:
> Reposting, apologies, hadn't noticed it had switched to HTML mail.
> Rich
> --- erlang@REDACTED wrote:
> From: "Richard Bowker" <erlang@REDACTED>
> To: <erlang-questions@REDACTED>
> Subject: [erlang-questions] Erlang 20 and crypto:rand_uniform/2
> Date: Tue, 16 May 2017 09:55:18 -0700
> Erlang 20-RC1 gives the following warning
> `crypto:rand_uniform/2 is deprecated and will be removed in a future
> release; use rand:uniform/1`
> Is there any reason why we wouldn't want to provide a rand:uniform/2
> with a matching Lo/Hi api for convenience of retrofitting?

Not really.  The rand module replaced the random module, and from there
came no uniform/2 function. It did not exist since it is so simple
to do it yourself.

The function crypto:rand_uniform/2 was created from the underlying
libcrypto function, which has the Lo,Hi arguments.

There is so little gain in a uniform/2 function that I do not think it
is worth implementing.  Maybe arity 2 should be used for somehing completely
different as an option list, distribution type, or whatnot...

> cheers
> Rich


/ Raimo Niskanen, Erlang/OTP, Ericsson AB

More information about the erlang-questions mailing list