std.algorithm.remove and principle of least astonishment

Steven Schveighoffer schveiguy at yahoo.com
Sat Oct 16 13:14:15 PDT 2010


On Sat, 16 Oct 2010 15:51:23 -0400, Andrei Alexandrescu  
<SeeWebsiteForEmail at erdani.org> wrote:

> On 10/16/2010 01:39 PM, Steven Schveighoffer wrote:
>> I suggest wrapping a char[] or wchar[] (of all constancies) with a
>> special range that imposes the restrictions.
>
> I did so. It was called byDchar and it would accept a string type. It  
> sucked.
>
> char[] and wchar[] are special. They embed their UTF affiliation in  
> their type. I don't think we should make a wash of all that by handling  
> them as arrays. They are not arrays.

The compiler thinks they are.  And they look like arrays (T[] looks like  
an array to me no matter what T is).  And I *want* an array of characters  
in most cases.  If you want a special type for strings, make them a  
special type.

D should not have this schizophrenic view of strings.  Plus it strikes me  
as extremely unclean and bloated for every algorithm that might have a  
range of char's passed into it to treat it specially (ignoring what the  
compiler says).

-Steve


More information about the Digitalmars-d mailing list