Semantic confusion alert!

EX3 (great document!) sez:

>       print "Inflation rate: " and $inflation = +<>
>                             until $inflation != NaN;

This requires that C<NaN != NaN> be false, causing the loop to continue
until a valid numeric string is entered. For IEEE-type NaN semantics,
that isn't so: C<NaN != NaN> is true! Try:

/* x86 Linux + gcc */
#include <math.h>
main()
{
  double nan = sqrt(-1);

  if(! (nan == nan)) printf("%f == %f is false\n",nan,nan);
  if(   nan != nan)  printf("%f != %f is true\n",nan,nan);
}

Perl6 can, of course, define any semantics for NaN that it chooses, but
there will be some confusion and dissonance if the choice above is made;
i.e. to make C<NaN != NaN> false.

The example can be rewritten

       print "Inflation rate: " and $inflation = +<>
                             while $inflation != $inflation;

That is ugly, non-intuitive and ugly; and non-intuitive too. But
inconsistency with a long accepted standard is also ungood. Perhaps we
need to write it thus:

       print "Inflation rate: " and $inflation = +<>
                             while $inflation.isnan;

or some such?

-- Tim Conrow

Reply via email to