Erlang 20 and crypto:rand_uniform/2

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Erlang 20 and crypto:rand_uniform/2

Richard Bowker
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?


cheers

Rich

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Erlang 20 and crypto:rand_uniform/2

Richard Bowker
Reposting, apologies, hadn't noticed it had switched to HTML mail.

Rich

--- [hidden email] wrote:
From: "Richard Bowker" <[hidden email]>
To: <[hidden email]>
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?
cheers
Rich

_______________________________________________ erlang-questions
mailing             list            [hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Erlang 20 and crypto:rand_uniform/2

Raimo Niskanen-2
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
>
> --- [hidden email] wrote:
> From: "Richard Bowker" <[hidden email]>
> To: <[hidden email]>
> 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
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Erlang 20 and crypto:rand_uniform/2

Pierre Fenoll-2
I am sorry but nothing of what you said is even close to a good reason to not provide a /2 providing the same API as crypto:rand_uniform/2.



_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Erlang 20 and crypto:rand_uniform/2

Raimo Niskanen-2
On Tue, Aug 08, 2017 at 11:10:33AM -0700, Pierre Fenoll wrote:
> I am sorry but nothing of what you said is even close to a good reason to
> not provide a /2 providing the same API as crypto:rand_uniform/2.

As I see it there is so far no good reason _for_ implementing rand:uniform/2,
and there are at least 2 possible variants:
    rand:uniform(Min, Max) -> Min + rand:uniform(Max - Min).
    rand:uniform(Min, Range) -> Min + rand:uniform(Range).

The current API is minimal, makes both easy and does not choose between them.
Small APIs are in general more beautiful and easier to maintain.

Best regards
--

/ Raimo Niskanen, Erlang/OTP, Ericsson AB
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions