Native Interop

Donna can call into C through FFI packages. This is useful when a mature C library already does the job well.

Good FFI packages keep the Donna API small and clear.

code
import markdown

pub fn main() -> Nil:
  echo markdown.to_html("# Hello Donna")

Put C source files in the package's ffi/ directory.

code
my_package/
  donna.toml
  src/
    my_package.donna
  ffi/
    my_package_ffi.c
    my_package_ffi.h

The Donna API lives in src/. The C wrapper lives in ffi/. Everybody knows where they stand.

For portable FFI:

FFI is powerful. Use it like Donna Paulsen uses a sentence: direct, sharp, and only when it matters.