Why foreach(c; someString) must yield dchar

Rainer Deyke rainerd at eldwood.com
Fri Aug 20 12:42:03 PDT 2010


On 8/20/2010 10:44, Simen kjaeraas wrote:
> First off, char, wchar, and dchar are special cases already - they're
> basically byte, short, and int, but are treated somewhat differently.

They're only special cases when placed in a built-in array.  In any
other container, they behave like normal types - unless the container
uses built-in arrays internally, in which case it may not work at all.

I have no objection to a string type that uses utf-8 internally but
iterates over full code points.  My objection is specifically to
special-casing built-in arrays to behave differently from all other
arrays when instantiated on 'char' and 'wchar'.  Rename 'char[]' to
'char""' (and keep 'char[]' as a simple array) and my objection goes away.

Again, I ask: what about 'Array!char'?


-- 
Rainer Deyke - rainerd at eldwood.com


More information about the Digitalmars-d mailing list