On this page:
_  fun

5.5 Static Callout and Callback Cores🔗ℹ

The ffi/unsafe/static library provides the same bindings as ffi/unsafe, but with a replacement _fun form.

Added in version 8.11.0.2 of package base.

syntax

(_fun fun-option ... maybe-args type-spec ... -> type-spec
      maybe-wrapper)
Like _fun from ffi/unsafe, but triggers an error at compile time in the CS implementation of Racket if the compiler is unable to infer enough information about the resulting C type to statically generate code for callouts and callbacks using the type.

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.