Skip Menu |
 

This queue is for tickets about the Scalar-List-Utils CPAN distribution.

Report information
The Basics
Id: 131536
Status: resolved
Priority: 0/
Queue: Scalar-List-Utils

People
Owner: Nobody in particular
Requestors: DBOOK [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 1.54



Subject: Changing rand implementation
Download (untitled) / with headers
text/plain 172b
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.
Download (untitled) / with headers
text/plain 238b
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.
Download (untitled) / with headers
text/plain 177b
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
Download (untitled) / with headers
text/plain 589b
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
This is now on CPAN as part of 1.54 -- Paul Evans


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.