[racket] Another basic TR question

From: Vincent St-Amour (stamourv at ccs.neu.edu)
Date: Thu Feb 13 14:56:00 EST 2014

At Thu, 13 Feb 2014 14:45:08 -0500,
Bloch Stephen wrote:
> Don't tell me the Zero I'm running into is the initial value of
> for/sum's hidden accumulator....

Yes, that's where the Zero comes from.

> And even if there were a zero, shouldn't Zero be a subtype of Flonum?

Zero is the type of the exact integer 0, but the Flonum type only
includes floating-point numbers. The two are not related by subtyping.


You can use `assert' to check, at run-time, that you do always get a
Flonum:

    (assert (for/sum: : Real [[ii : Index 300]]
              pi)
            flonum?)

This expression typechecks at type Flonum.

Vincent


Posted on the users mailing list.