Why foreach(c; someString) must yield dchar
Steven Schveighoffer
schveiguy at yahoo.com
Mon Aug 23 04:46:44 PDT 2010
On Wed, 18 Aug 2010 23:11:26 -0400, Rainer Deyke <rainerd at eldwood.com>
wrote:
> On 8/18/2010 20:37, dsimcha wrote:
>> I've been hacking in Phobos and parallelfuture and I've come to the
>> conclusion
>> that having typeof(c) in the expression foreach(c; string.init) not be
>> a dchar
>> is simply ridiculous.
>
> I have long ago come to the opposite conclusion. An array of 'char'
> should act like any other array. If you want a sequence of 'dchar' that
> is internally stored as an array of 'char', don't call it 'char[]'.
I have to agree with Rainer here. I think maybe string shouldn't just be
an immutable(char)[]. I'd rather see it as a struct that wraps a char[]
and presents the appropriate interface.
Ditto for wchar.
-Steve
More information about the Digitalmars-d
mailing list