Tue Jan 21 16:16:13 2020DBOOK [...] cpan.org - Ticket created
Subject:
Changing rand implementation
It would be nice to be able to specify a different rand implementation to be used by shuffle as well as my proposed sample function (#131535), such as Math::Random::Secure.
Wed Jan 22 07:50:38 2020haarg [...] haarg.org - Correspondence added
What would a good interface for this be? My first thought is something like
local $List::Util::RAND = \&Math::Random::Secure::rand;
Having a sub like set_rand would be another option, but that doesn't allow localizing the value easily.
Wed Jan 22 07:50:38 2020The RT System itself - Status changed from 'new' to 'open'
Wed Jan 22 09:33:59 2020DBOOK [...] cpan.org - Correspondence added
On Wed Jan 22 07:50:38 2020, haarg wrote:
Show quoted text
> local $List::Util::RAND = \&Math::Random::Secure::rand;
This seems fine to me, being able to localize the change is important.
-Dan
Mon Jan 27 19:35:03 2020leonerd-cpan [...] leonerd.org.uk - Correspondence added
I like the idea of `local`ing a variable.
As things stand this would be annoyingly nontrivial to implement though, because List::Util::shuffle() is an XS function, not PP. It's also the only place in Scalar-List-Utils(featuring-Sub-Util) where rand() is used.
A much simpler implementation might be to make a new shuffling function that took a randfunc as its first argument. That could then be in pureperl and be much simpler to write.
Though that presupposes the module doesn't gain more rand-using functions; if it does that might suggest a variable would be better.
--
Paul Evans
Wed Jan 29 08:49:31 2020leonerd-cpan [...] leonerd.org.uk - Correspondence added