4 ms·
Where does the conversion between C's simple "float" and Scheme's notion of numbers take place? Does the call from "#lang racket" check and convert the argumen
by username223 9y ago
Where does the conversion between C's simple "float" and Scheme's notion of numbers take place? Does the call from "#lang racket" check and convert the arguments before passing to a simple f(), or does a complex f() check and convert its parameters?
- shakna 9y agoIt depends on the implementation, that's for the expander to handle. In the case of the implementation I listed, it passes it on literally, and compiles it and runs it, and then takes the output and passes it back to Racket. [0] [0] https://github.com/jeapostrophe/c/blob/master/c/lang/runtime.rkt https://github.com/jeapostrophe/c/blob/master/c/lang/runtime...
- username223 9y agoIt shells out to the C compiler (hard-coded as "cc") for every function? Oof. That's a pretty limited FFI. Or maybe I wasn't clear. If Scheme tries to pass a double/bignum/whatever to the C function that expects the float, where is the error caught?
- shakna 9y agoIt's not Scheme that does the passing, just to be clear, it's the library. In this case, it's just throwing strings around without changing anything. No passing to transform a bignum, no bounds checking. Just tries to run it. (Racket does have a decent FFI [0], but this library is just for classroom example stuff. Not serious work.) [0] https://docs.racket-lang.org/foreign/index.html https://docs.racket-lang.org/foreign/index.html