Bug 13256 – Update std.array.front to support all strings uniformly

Status
RESOLVED
Resolution
WONTFIX
Severity
enhancement
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2014-08-04T19:18:00Z
Last change time
2016-06-27T19:54:50Z
Assigned to
nobody
Creator
maidenphil

Comments

Comment #0 by maidenphil — 2014-08-04T19:18:01Z
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!
Comment #1 by jack — 2016-06-27T19:54:50Z
This is not going to be fixed, at least not in D2. Just search for "auto-decoding" in the news group for the discussions.