Help: Where to find ffi/examples

Hi, I am learning racket FFI. I want to see more examples. Can someone tell me where to find ffi/examples mentioned in the FFI doc?

4 Likes

I recommend using raco whereis to find locally-installed things. You can install it with raco pkg install whereis. Then:

$ raco whereis -c ffi/examples
/path/to/racket-8.4/share/pkgs/racket-doc/ffi/examples

The -c means find a "collection", which is like a directory of module names. (Some collections, such as racket, are spread over multiple physical directories.)

So, it seems to be part of the racket-doc package.

5 Likes

The same collection on github:

A few extra examples:

And a nice blog post:

6 Likes

This is incredible. I'm currently adding types to a fork of @Eutro's racket-raylib library for a small 2d game I'm working on. I want the compile time errors because when I pass the wrong types to a function or struct (like supplying Integers instead of Floats to Rectangles) in the main loop after the window is created, Racket crashes and the window becomes unresponsive until I open task manager and manually kill the task. I've been struggling with how to type some of the more complex values and this is an invaluable resource

3 Likes