dmd foreach loops throw exceptions on invalid UTF sequences, use replacementDchar instead
kdevel
kdevel at vogtner.de
Sun Nov 7 16:28:33 UTC 2021
On Sunday, 7 November 2021 at 04:18:25 UTC, Walter Bright wrote:
> On 11/4/2021 11:30 PM, FeepingCreature wrote:
>> [...] Let them crash, [...] 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.
Technically it makes no difference if you do not check for 0.0 or
not for NaN. What makes a difference is using "out of band
signalling" (exceptions) if its default behavior is process
termination.
> NaN and ReplacementChar are not valid
The replacemment character '�' is a valid Unicode codepoint
(U+FFFD).
> and are easily distinguished.
Someone may forget to write explicit code to handle this case
which most likely leads to data corruption. I choose stack trace
over potentially corrupted data.
More information about the Digitalmars-d
mailing list