std.algorithm and immutable arrays

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Wed Jun 9 17:41:48 PDT 2010


I'm thinking of the recently discussed problem and it seems that 
immutable arrays are an issue not only for find(), but for all functions 
that need ranges.

To fix things I'd need to add code for detecting immutable(T[]) and 
converting it to immutable(T)[] for _every_ algorithm using ranges out 
there. That would make things worse from a readability standpoint.

So we're looking at a number of options:

(a) Leave things as they are. To use std.algorithm with immutable arrays 
you need to peel off the top-level immutable.

(b) Promote a change in the compiler to convert immutable(T[]) to 
immutable(T)[] when passed by value into a function. This is safe and 
sensible.

(c) Bludgeon std.algorithm to work with immutable(T[]).

What say you?


Andrei


More information about the Digitalmars-d mailing list