A Philosophy of Software Design

H. S. Teoh hsteoh at qfbox.info
Sun Jun 28 02:28:01 UTC 2026


On Sat, Jun 27, 2026 at 07:15:37PM -0700, Walter Bright via Digitalmars-d wrote:
> On 6/27/2026 5:13 PM, Forum User wrote:
> > On Saturday, 27 June 2026 at 19:48:44 UTC, Walter Bright wrote:
> > > [...]
> > > It behaves much like the floating point NaN value, which is a
> > > generally misunderstood and underappreciated.
> > 
> > NaNs increase hidden complexity and require more source code
> > (i.e. increase source code complexity) in order to do things right:
> > 
> >     auto t = (t2);
> >     if (t < 2.0)
> >        writeln ("met the climate target");
> >     else
> >        writeln ("failed to meet the climate target");
> 
> The reader would want to know how well the number met the target, or how
> badly it failed:
> 
> ```d
> if (t < 2.0)
>      writeln ("%g met the climate target", t);
> else
>     writeln ("%g failed to meet the climate target", t);
> ```
> 
> Besides, getting a NaN result is always better than getting an
> arbitrary number with no clue whether it is valid or a bug.

In an exception-based system you'd get an exception, not an arbitrary
number.  Same difference.

Besides, even if you *don't* get a NaN, it doesn't mean there wasn't a
bug. The calculation itself can still be faulty, and you still have the
same problem of how much to trust the result.


T

-- 
Those who don't understand D are condemned to reinvent it, poorly. -- Daniel N


More information about the Digitalmars-d mailing list