[Issue 13256] New: Update std.range.ElementType to support all strings uniformly
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Aug 4 12:18:01 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=13256
Issue ID: 13256
Summary: Update std.range.ElementType to support all strings
uniformly
Product: D
Version: D2
Hardware: x86_64
OS: Windows
Status: NEW
Severity: enhancement
Priority: P1
Component: Phobos
Assignee: nobody at puremagic.com
Reporter: maidenphil at hotmail.com
K so I played around and noticed that the type of std.array.front for strings
and wstrings is dchar, but immutable(dchar) for dstrings.
It turns out that std.array.front makes a distinction when it's a narrow string
(as per std.traits.isNarrowString) and dstring is not one. I think the
distinction is made to avoid decoding when unnecessary.
However, that distinction results in some lack of consistency. Here are my
propositions:
1 - std.array.front returns dchar for all strings
2 - Consider reviewing std.array so that it does not make a distinction whether
it's a string or not. Indexing in a string produces an immutable(char). A range
wrapper around a string located in an array module should produce the same type
in my opinion. In the case somebody needs to decode a string, provide a range
wrapper in std.utf.
Thx!
--
More information about the Digitalmars-d-bugs
mailing list