Capy-Bearer Documentation

call

lib call

Capy

function call(handle : module, name : string, input : as any = {}, request : capture any) any

Description

call() calls an exported function in a loaded unit. It returns the result as any.

Use unit_load() once when several calls use the same unit. The two-argument form passes an empty map to the export's required any input.

Use call(handle, name, input) when the export name is a value. handle.echo(input) is the member-call spelling for a fixed name. Both calls share input and result objects with the target. Printed output is separate from the return value.

The target export must have the exact signature (any) any. For a fixed unit path and export name, prefer #import so the compiler checks both.

Parameters

request : the caller's request, captured when omitted

handle : a value from unit_load()

name : an exported function name

input : optional any input

Return Values

The exported function result.

Errors

An unavailable export, incompatible signature, or invalid module handle stops the request with a runtime error. The result is not an availability or error-status map.

Example

Capy

var handle := unit_load("/doc/examples/call_target.capy")
var result := call(handle, "echo", name: "Ada")
print(result.name, "\n")

Output

Ada