[Issue 14519] [Enh] foreach on strings should return replacementDchar rather than throwing

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Apr 29 03:26:18 PDT 2015


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

--- Comment #13 from Walter Bright <bugzilla at digitalmars.com> ---
Vladimir, you bring up good points. I'll try to address them. First off, why do
this?

1. much faster

2. string processing can be @nogc and nothrow. If you follow external
discussions on the merits of D, the "D is no good because Phobos requires the
GC" ALWAYS comes up, and sucks all the energy out of the conversation.

So, on to your points:

1. Replacement only happens when doing a UTF decoding. S+R doesn't have to do
conversion, and that's one of the things I want to fix in std.algorithm. The
string fixes I've done in std.string avoid decoding as much as possible.

2. Same thing. (Running normalization on passwords? What the hell?)

The replacement char thing was not invented by me, it is commonplace as users
don't like their documents being wholly rejected for one or two bad encodings.

I know that many programs try to guess the encoding of random text they get.
Doing this by only reading a few characters, and assuming the rest, is a
strange method if one cares about the integrity of the data.

Having to constantly re-sanitize data, at every step in the pipeline, is going
to make D programs uncompetitive speed-wise.

--


More information about the Digitalmars-d-bugs mailing list