[Issue 9106] Rename std.random.randomShuffle as std.random.shuffle and small usage change

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Mar 22 08:14:18 PDT 2014


https://d.puremagic.com/issues/show_bug.cgi?id=9106


Ivan Kazmenko <gassa at mail.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gassa at mail.ru


--- Comment #8 from Ivan Kazmenko <gassa at mail.ru> 2014-03-22 08:14:10 PDT ---
Initially, I would have been against the renaming.  The main argument would be
that what we have now is consistent as a set of randomization functions
operating on ranges, and consistent with use in other languages.  For example,
wouldn't it be inconsistent to rename some of the functions (shuffle and
sample) but not others (randomCover)?

But then, a quick search on modern languages revealed they favor the shorter
shuffle/sample names.  For example, C++ has a legacy random_shuffle but a
modern C++11 shuffle for use with C++11 RNGs.  Python has shuffle and sample. 
Java has shuffle.  So, the second part of my argument is no longer valid.

So, for me, the problem reduced to whether randomCover could use a wholly
different, better name.  So, how is this function called in other languages?

By the way, randomCover is terribly inefficient as of DMD 2.065.0 (quadratic in
total), is that addressed somehow in random2?  I have a linear-time approach
with an associative array in mind, but that would mean reallocating when the AA
grows, which is something to avoid for Phobos code, right?

Ivan Kazmenko.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list