[Larceny-users] ffi support for Integer to float

Eduardo Cavazos wayo.cavazos at gmail.com
Fri Feb 6 19:23:59 EST 2009


Hello,

Example using 'gl':

     (glColor4d 1 1 1 1)

Of course, this produces an error since the 'glColor4d' expects double
arguments.

However, it's no fun to litter the code with 'exact->inexact'. Another
approach I take is to do (+ 0.0 n).

So my question is, in the future, will the ffi work such that numeric
conversions such as these happen automatically? If not, then I suppose
the solution is a "higher level" library which does things like:

(define (gl-color r g b a)
   (glColor4d (exact->inexact r)
          (exact->inexact g)
          (exact->inexact b)
          (exact->inexact a)))

will be in order.

It seems like integer->float conversions seem conservative while the
reverse isn't prudent.

Ed



More information about the Larceny-users mailing list