[racket-dev] Inferring numeric function types from representative argument values

From: Sam Tobin-Hochstadt (samth at ccs.neu.edu)
Date: Fri Jan 4 08:53:15 EST 2013

On Thu, Jan 3, 2013 at 11:09 PM, Neil Toronto <neil.toronto at gmail.com> wrote:
> (In particular, platform-independent Index and Fixnum types scare me.)

Platform-independent Fixnum is easy -- just if |x| <= 2^30, then x is
a fixnum on all platforms Racket supports. [1]

Index is a little trickier, since it's not documented as part of plain
Racket.  Typed Racket assumes that indicies are 2 bits shorter than
fixnums, so `(index? n)` is true iff `(and (fixnum? n) (>= n 0)
(fixnum? (* n 4)))`.

Sam

[1] http://docs.racket-lang.org/guide/performance.html?q=fixnum#%28tech._fixnum%29

Posted on the dev mailing list.