[Issue 19518] std.range.front() returns a dchar when applied to char[]

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Feb 14 10:11:08 UTC 2019


https://issues.dlang.org/show_bug.cgi?id=19518

--- Comment #7 from Seb <greeenify at gmail.com> ---
Well, we all agree that it's not super nice, but it also has advantages.
Take e.g. 'ü'. If .front would only return a char, you would get the invalid
utf symbol. Try printing "ü"[0]

Yes, it has downsides though, but with ElementType!R or auto must generic
algorithms don't care about the actual return of .front and if they do, they
need special casing for strings anyhow.

Auto-decoding by default is considered as the top2 design error of D, but it's
super hard to fix it now. The solutions so far are:
- fork std.range
- use byCodeUnit or similar
- use rcstring (or similar)

If you come up with a better idea, please share it in the NG, but we can't
change std.range.front because it would break room of code. Thanks!

--


More information about the Digitalmars-d-bugs mailing list