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

Walter Bright newshound2 at digitalmars.com
Sun Nov 7 04:18:25 UTC 2021


On 11/4/2021 11:30 PM, FeepingCreature wrote:
> 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's much better than 0.0. 0.0 is indistinguishable from valid data, and is a 
very common valid value.

NaN and ReplacementChar are not valid and are easily distinguished.


More information about the Digitalmars-d mailing list