Oh wow! IIUC it is super awesome. Would a natural next step be #lang terra <http://terralang.org/>? Hey Jay McCarthy would you like to mentor that effort ;-)
On Saturday, 1 June 2019 20:06:29 UTC+1, David Benoit wrote: > > Hi All, > > I've recently released a new library > <https://pkgs.racket-lang.org/package/dynamic-ffi> for dynamically > generating FFI bindings to C by parsing header files. > It also allows users to create FFI libraries by writing C functions > directly inline in Racket programs. > > The library works as a native extension to Racket by linking with Clang's > parser libraries and converting AST declarations into FFI objects. > As a result, the package depends on Clang and LLVM headers and libraries. > See the documentation > <https://docs.racket-lang.org/dynamic-ffi/index.html> for info on > installing dependencies. > > I've only built the package on GNU/Linux so far. If anyone is interested > in building the library on other OSes, it should be a fairly trivial port. > > I'd like to give a special thanks to Jay McCarthy, who came up with the > idea for this project and was my adviser during its implementation. > I hope its something the Racket community might find useful! > > More usage examples are available in the docs and the test directory > <https://github.com/dbenoit17/dynamic-ffi/tree/master/test> in the source > code. > > Thanks! > David B > > I'll sign off with a quick preview: > > #lang at-exp racket/base > > (require dynamic-ffi/unsafe) > > @define-inline-ffi[struct-test]{ > #include <stdlib.h> > #include <stdio.h> > #include <stdint.h> > > typedef struct { > char *name; > uint64_t value; > } number; > > char* names[] = {"zero", "one", "two", "three", "four", "five", "six" > "seven", "eight", "nine", "ten", "eleven", "twelve"}; > > number add(number a, number b) { > number c; > c.value = a.value + b.value; > if (c.value >12) { > fprintf(stderr, "error: this example can only count to twelve...\n"); > exit(1); > } > c.name = names[c.value]; > return c; > } > } > > ;; _list-structs are created by default. I hope to optimize this in the > future. > > (define n2 (list "two" 2)) > > (define n7 (list "seven" 7)) > > (printf "add(n2, n2): ~a\n" (struct-test 'add n2 n2)) ;; output: add(n2, > n2): (four 4) > (printf "add(n7, n7): ~a\n" (struct-test 'add n7 n7)) ;; output: error: this > example can only count to twelve... > > > > > > -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/628bf864-d261-481b-962c-2e54be297228%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.