
Don’t know if this has been worked on but it would be super useful to have a a #lang which could fully parse C prototypes, typedefs, structs, unions, etc and translate them to FFI calls. Then, hooking up C functions would be as easy as it’s done in luajit. [It’s beyond my abilities at this time in Racket experience]

@steveh2009 Have you seen http://prl.ccs.neu.edu/blog/2016/06/27/tutorial-using-racket-s-ffi/ ?

Yes, I’ve started reading this today which had me thinking about luajit’s way of expressing its CFFI

Your tutorial is excellent. But how good would it be to have a virtually zero barrier to FFI entry?

@xizhao there’s already a library that does some of this; https://docs.racket-lang.org/c-utils/index.html

I am a little skeptical. The LuaJit page says: Given that the FFI library is designed to interface with C code and that declarations can be written in plain C syntax, it closely follows the C language semantics, wherever possible.

This means that using the FFI will feel like writing a C program.

The Racket FFI attempts to automate (or at least make it easier) to write bindings, whose users don’t need to know the underlying C library.

Eli and Dmitry explain it well here: https://pdfs.semanticscholar.org/161e/43694437e9174364178cde38cc945f205987.pdf?_ga=2.187719784.1967315547.1571322213-1939662795.1565520704

@samth Do you think that library could be used as-is for the basis of an FFI code generator?

probably

There’s a site called http://luapower.com\|luapower.com. It’s a repository for C libs callable from luajit. How much effort would it take to get them all working with Racket? Too much. If Racket could utilize luajit’s top-level interface, well, they’ve done all the work of describing the C interfaces for luajit input. It’s basically cut and paste, Racket library to make the translation to its CFFI…done: a pretty serious productivity tool. Could be a GSOC project topic?

Hi @mflatt, I am trying to build Racket-on-Chez in development mode:

I ran ./configure

I got no suitable machine type found
try rerunning as ./configure -m=<machine type>
available machine types: *

Then I ran ./configure —help:

Available machine types: *
Examples:
./configure --machine=i3le
set machine-type to i3le rather than to determined type
./configure --threads --installprefix=/usr/local
specify threaded version and set installation directory to /usr/local.

BTW, I am on macOS 10.14. What machine type should I use?

The problem is that the instructions don’t mention a bootstrap step, where you need Racket to start building Chez Scheme.

In the ChezScheme
directory, you want to run racket <racket-repo>/racket/src/cs/bootstrap/main.rkt

Or raco pkg install cs-bootstrap
and then racket -l cs-bootstrap
. That assumes that raco
and racket
is one built in the current Racket repo.

@pocmatos @notjack I would also like to follow this conversation

it hasn’t started yet but fine by me :simple_smile:

Hi folks. Here’s an update on integrating Vulkan and Racket: https://sagegerard.com/racket-vulkan-types-done.html

Exciting. I’ve wanted to work with Vulkan in Racket for a bit now.

Ditto. I’m looking for feedback on the binding definitions themselves, since this is the first time I’ve used ffi/unsafe
.

@steveh2009 Jay recently introduced me to https://github.com/dbenoit17/dynamic-ffi, which might be of interest to you

I remember checking out that XML before. You’re a brave individual.

dynamic-ffi: darn, I’m on Windows 10.