SNOBOL4FFI(3)
π SNOBOL4FFI π
okay so this is from the CSNOBOL4 Manual, and bestie, it's literally the page that lets your SNOBOL4 code reach out and touch actual C libraries. Foreign Function Interface energy. no cap.
β¨ NAME β¨
snobol4ffi β the Foreign Function Interface for SNOBOL4. yes queen, your interpreter can call external functions now π«Ά
πΈ SYNOPSYS πΈ
-INCLUDE 'ffi.sno'
dl = FFI_DLOPEN("/usr/lib/libm.so")
sym = FFI_DLSYM(dl, "hypot")
DEFINE_FFI("hypot(double,double)double", sym)
OUTPUT = hypot(3, 4)
like, that's the whole vibe. include the file, open the lib, grab the symbol, define the function, call it. iconic four-step. π
π DESCRIPTION π
Three little functions that make the magic happen. here's the tea:
FFI_DLOPEN(filename)β you hand it the path of a dynamically loadable executable file, and it hands you back a value. keep that value safe, because it's the thing you pass toFFI_DLSYM(). β¨FFI_DLSYM(library,function)β takes a library value that came back fromFFI_DLOPEN(), plus a function name, and gives you back a value that you can pass straight intoDEFINE_FFI(). it's giving matchmaker, lowkey. πΈDEFINE_FFI(prototype,pointer)β this is the main character. it defines a SNOBOL4 function that calls an external function viaffi(3).prototypeholds a string name for the function, followed by a comma separated list of parameter types inside of parentheses β any of:sint8,sint16,sint32,sint64,uint8,uint16,uint32,uint64,schar,sshort,sint,slong,uchar,ushort,uint,ulong,float,double,longdouble,pointerβ and then a return type, which can be any of the above parameter types, orvoid,string,freestring.pointeris a value returned byFFI_DLSYM(). π₯
fr fr though, get that type list right β every single one of those names matters, so don't be out here freestyling. π«Ά
π SEE ALSO π
snobol4(1), ffi(3), dlopen(3) β go read those too, bestie, they're the supporting cast π
π AUTHOR π
Philip L. Budne β king behavior. π
Inspired by an FFI interface by Fred Weigel β¨
okay that's the whole page, slay. π¦ this cutie is from CSNOBOL4B 2.3.5, dated October 18, 2026 β literally stamped and everything. ππ§
π¦ where this page comes from
- nixpkgs unstable: snobol4 2.3.5
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms