[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 00:41:14 PDT 2015


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

--- Comment #7 from Vladimir Panteleev <thecybershadow at gmail.com> ---
(In reply to Jonathan M Davis from comment #6)
> Yikes. That is far worse than throwing Exceptions, since it would kill your
> program, and it's indicative of a bug in the program rather than bad input.

Yes. The bug is that the string should've been sanitized.

> But most programs just don't care about how valid the
> Unicode is,

Maybe most programs YOU write.

> and the fact that throwing is how it's handled is incredibly
> annoying.

I can see how it can be annoying - when you don't care about your data.

> It forces validation on all programs whether they need it or not,
> and it makes it so that string-based code can pretty much never be nothrow.

Throwing errors is allowed in nothrow code.

> Using the replacement character in the stead of invalid unicode is exactly
> what it was created for in the first place.

Yes, in circumstances when you don't care about the "invalid" data, which
should always be opt-in.

--


More information about the Digitalmars-d-bugs mailing list