importVariable (schema name --)

Inputs

Outputs

schema supplies only the imported local's schema. Its current value is not imported.

The builtin creates a new local named exactly name in the current scope. That local refers to external variable storage of the selected schema.

After creation, the imported name participates in normal local lookup. Bare mention, @NAME, and !NAME therefore follow the normal MPL rules for a local of the selected schema.

This builtin declares an external variable name only. It does not create a local from an existing stack object, and it does not declare an external callable name.

Behavior

Known issue: creation can emit invalid LLVM IR even when the imported variable is unused; Clang reports global variable reference must have pointer type. Use an imported accessor function for runtime access.

Example

A fully runnable positive example also requires a separately defined external variable of the requested schema. This page therefore records the creation and lookup rules instead of a standalone executable example.

See also