Continuing the exploration @tealeg sparked yesterday: lazy-ffi in Chicken Scheme is nice.

$ csi
CHICKEN
(c) 2008-2021, The CHICKEN Team
(c) 2000-2007, Felix L. Winkelmann
Version 5.3.0 (rev e31bbee5)
linux-unix-gnu-x86-64 [ 64bit dload ptables ]

Type ,? for help.
#;1> (import lazy-ffi)
; loading /var/lib//chicken/11/lazy-ffi.import.so ...
; loading /var/lib//chicken/11/lazy-ffi.so ...
; loading /var/lib//chicken/11/srfi-1.so ...
; loading /var/lib//chicken/11/srfi-69.so ...
; loading /var/lib//chicken/11/bind.so ...
#;2> (begin #~"libc.so.6")
(libc.so.6)
#;3> (#~printf "Hello, world. Mom is #%d! We %s her!\n" 1 "love")
Hello, world. Mom is #1! We love her!

https://wiki.call-cc.org/eggref/5/lazy-ffi

#chicken #scheme #ffi

lazy-ffi - The CHICKEN Scheme wiki

@mason I do like the way lazy-ffi uses read syntax, though you could of course do something similar with normal macros. I’m slowly exploring the forces on the Haiku API and I’m tempted to make a syntactic shortcut for this stuff. I won’t go too early though. Premature macroisation can really spoil things.

@mason @tealeg neat! i can pledge() my programs easily now!

~ $ rlwrap chicken-csi CHICKEN (c) 2008-2022, The CHICKEN Team (c) 2000-2007, Felix L. Winkelmann Version 5.4.0 (rev 1a1d1495) openbsd-unix-clang-x86-64 [ 64bit dload ] Type ,? for help. #;1> (import lazy-ffi) ; loading /usr/local/lib/chicken/11/lazy-ffi.import.so ... ; loading /usr/local/lib/chicken/11/lazy-ffi.so ... ; loading /usr/local/lib/chicken/11/srfi-1.so ... ; loading /usr/local/lib/chicken/11/srfi-69.so ... ; loading /usr/local/lib/chicken/11/bind.so ... #;2> (import chicken.memory) ; loading /usr/local/lib/chicken/11/chicken.memory.import.so ... #;3> (begin #~"libc.so") (libc.so) #;4> (define null (address->pointer 0)) #;5> (define rc (#~pledge "stdio" null)) #;6> (print rc) #<unspecified> #;7> (#~printf "pledged\n") pledged #;8> (#~open "/etc/passwd" 0) chicken-csi[81735]: pledge "rpath", syscall 5 rlwrap: warning: chicken-csi crashed, killed by SIGABRT. rlwrap itself has not crashed but, for transparency, it will now kill itself (without dumping core) with the same signal warnings can be silenced by the --no-warnings (-n) option zsh: abort rlwrap chicken-csi ~ $