Summary: Fix or disallow randomShuffle() on fixed-sized arrays
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos

--- Comment #0 from 2012-05-03 13:45:51 PDT ---
This comes after a report by Vidar Wahlberg:$rjr$

Several functions of std.algorithm don't work with fixed-sized arrays, and
require you to slice them first to turn them into ranges. But
std.random.randomShuffle() accepts fixed-sized arrays as well:

import std.stdio: writeln;
import std.random: randomShuffle;
void main() {
    int[6] data = [1, 2, 3, 4, 5, 6];

This prints the unshuffled array:
[1, 2, 3, 4, 5, 6]

This is bug-prone, and in my opinion it's not acceptable.

I see two alternative solutions:
1) To make randomShuffle() properly support fixed-sized arrays, taking them by
2) To make randomShuffle() refuse a fixed-sized array at compile-time.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to