www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13256] New: Update std.range.ElementType to support all


          Issue ID: 13256
           Summary: Update std.range.ElementType to support all strings
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: Phobos
          Assignee: nobody puremagic.com
          Reporter: maidenphil 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
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.


Aug 04 2014