5.5 Static Callout and Callback Cores
(require ffi/unsafe/static) | package: base |
Added in version 8.11.0.2 of package base.
The type-spec forms and some fun-option forms within _fun are arbitrary expressions that can compute C types and options at run time. If the optimizer can statically infer underlying representations, then it can generate the necessary code for a callout or callback statically, instead of deferring code generation to run time. This optimization applies even when using _fun from ffi/unsafe, but _fun from ffi/unsafe/static insists that the optimization must apply.
Currently, the benefit of static generation for callout and callback code is limited, because run-time code generation is fast and cached. In the long run, static generation may provide more benefit.