I'm thinking about how to explain Perl 6's numbers to the beginners
just picking up Learning Perl 6. I had some questions about NaN and Inf
(which I can't just try since neither Parrot or Pugs appear to know
about these yet).

* In S02's table of "Immutable types",  it mentions that Int allows Inf
and NaN, but doesn't say anything about Num and Complex handling them. 
Is it that it's unexpected that Int would handle it, so you have to say
this explicitly, or um, I don't have a good alternative :)

   Int         Perl integer (allows Inf/NaN, arbitrary precision, etc.)
   Num         Perl number
   Complex     Perl complex number

The complex and num  native type handles NaN accroding to "Native
type", a couple of subsections back, and I'm confident that Num and
Complex should have them too. It just looked odd to me that only one of
Int, Complex, and Num said anything about it.

* will NaN, -Inf, or +Inf be literal values (or something close) so I
can use them in comparisons? e.g. $x ~~ NaN. I see uses of Inf in list
creation ( 1 .. Inf ), but can I use that everywhere?

* If I can match $x to NaN (or its stand-in), what happens when $x is
undef? There's a note about this in S02 ("Conjecture: num might ...").
"Native type" say that an int type defaults to 0, which complicates
things for beginners, but if everything starts off as a num, it doesn't
matter until we talk about types.

* If I declare a sub to return a number of some sort (either by using
C<of> or C<as>, what happens when the value is NaN or Inf? I suppose
that should be fine as a return value, but it also seems that if
someone wants to impose some sort of constaint on the return value that
they wouldn't want exceptional values.

Reply via email to