[gambit-list] automatic int -> double conversion

Marc Feeley feeley at iro.umontreal.ca
Tue May 19 16:31:39 EDT 2009


On 19-May-09, at 3:48 PM, lowly coder wrote:

> I have a C/ffi function that expects a double as an argument.
>
> If I do (foo 0.0) <-- works fine
>
> if I do (foo 0) <-- complains about int / double mismatch; which  
> makes sense. Is there a way to automatically have gambit convert  
> ints to doubles?

Gambit's FFI doesn't currently have such a "lenient" double type.  You  
can do that by wrapping your function like this:

(define (lenient-foo x)
   (foo (exact->inexact x))

Marc




More information about the Gambit-list mailing list