Re: The value of +hello

2005-08-16 Thread Larry Wall
On Sun, Aug 14, 2005 at 03:48:22PM +0200, Daniel Brockman wrote:
: Exegesis 3 contains this snippet,
: 
:my $inflation;
:print Inflation rate:  and $inflation = +
:until $inflation != NaN;
: 
: but the rule that +hello evaluates to NaN is no longer
: mentioned in S03, according to Autrijus.
: 
: He suggested I post here to get a ruling.

I'm not sure it ever was mentioned in S03, but we'd like to stick as
close as we can to IEEE floating point, and that includes NaN as
a value that can be stored not only in a Num but also in a num.
(Along with +Inf and -Inf).  I suppose machines that don't do IEEE
floating point will have to emulate num with Num.

If we go with class names being the undefined prototypical values,
and if we assume that NaN is an unthrown exception variant of
the undefined value for object types like Num, then we might even
end up with Num == NaN, albeit with different exception information
hidden inside.  Num is not yet defined, whereas NaN is tried to
convert 'hello' to number at inflate line 2 or some such.

Larry


Re: The value of +hello

2005-08-16 Thread Larry Wall
On Tue, Aug 16, 2005 at 10:00:14AM -0700, Larry Wall wrote:
: If we go with class names being the undefined prototypical values,
: and if we assume that NaN is an unthrown exception variant of
: the undefined value for object types like Num, then we might even
: end up with Num == NaN, albeit with different exception information
: hidden inside.  Num is not yet defined, whereas NaN is tried to
: convert 'hello' to number at inflate line 2 or some such.

I forgot to point out that you naturally lose that extra exception
information when you store a Num into a num.  Whether that warns or
throws an exception or is silent is likely controlled by pragma.
People doing complicated things with large matrices might prefer
silence, whereas people doing scalar ops will usually prefer to know
that something went wrong sooner, and not have to backtrace through
the code to figure out where the NaN was generated.  But maybe most
of that naturally falls out of the num/Num distinction, since num
will mostly be used in compact arrays.

Larry