[racket-dev] flonum vs. inexact-real

From: Sam Tobin-Hochstadt (samth at ccs.neu.edu)
Date: Sun Oct 3 11:24:54 EDT 2010

On Sun, Oct 3, 2010 at 10:42 AM, Matthew Flatt <mflatt at cs.utah.edu> wrote:
> The `flonum?' predicate would be the only new predicate for now. The
> `inexact-integer?' predicate would imply `flonum?', but not vice-versa.

I assume you mean `inexact-real?' here.

> The flonum operators (with names that start `fl' or `unsafe-fl') would
> require and produce flonums, only.

I worry that this is a hazard for existing code.  For example, this
plain Racket code:

(define/contract (f x)
  (inexact-real? . -> . inexact-real?)
  (unsafe-fl+ x 3.2))

goes from being a safe optimization to potentially segfaulting.
Similarly (but less bad), this Typed Racket code:

(: f : Any -> Float)
(define (f x)
  (if (inexact-real? x)
      (fl+ x 3.2)
      0.0))

which currently typechecks would now be a type error.

I don't know how much we should worry about this, but we should
probably worry at least a little.
-- 
sam th
samth at ccs.neu.edu


Posted on the dev mailing list.