dmd foreach loops throw exceptions on invalid UTF sequences, use replacementDchar instead

norm norm.rowtree at gmail.com
Fri Nov 5 10:09:40 UTC 2021


On Friday, 5 November 2021 at 06:30:02 UTC, FeepingCreature wrote:
> On Friday, 5 November 2021 at 00:38:59 UTC, Walter Bright wrote:
>> [...]
>
> I think the program should crash in all these cases. The text 
> editor should crash. The browser should crash. The analyzer 
> should see a NaN, and crash.
>
> These programs are *wrong.* They thought they could only get 
> Unicode and they've gotten non-Unicode. So we know they're 
> written on wrong assumptions; why do we want to continue 
> running code we know is untrustworthy? Let them crash, let them 
> be fixed to make fewer assumptions. Automagically handling 
> errors by propagating them in an inert form robs the developers 
> and users of a chance to avoid a mistake. It's no better than 
> 0.0.

It isn't always that simple, e.g. working on medical devices 
crashing isn't an option when it comes to how we're going to deal 
with bad data.


More information about the Digitalmars-d mailing list