Lesson 13: The Foreign Function Interface
To allow use of external libraries, Toka provides a simple Foreign Function Interface (called FFI for short). This is built around the following primitives:
from LIBRARY
Set the import source to LIBRARY. This should be a fully-qualified filename; it may require a path as well as the .so extension.
N import FUNCTION
Imports a function named FUNCTION from the previously loaded library. A new quote named FUNCTION will be created, and will take N arguments off the stack. The imported function will always have a return value, even for void functions.
You may want to make use of as to rename the imported function.
Example:
#! Load libc. On Linux, this is libc.so.6, but on BSD it's libc.so from libc.so.6 2 import printf as printf.2 " %i\n" 100 printf.2
changed September 16, 2007