title: “CALLBACK” author: “laplante@plcb.ca” date: 2023-09-06 version: “1.0.0”
Callbacks are used to execute a function automatically when certain events occur in the runtime.
They are typically invoked when:
if
or for
is exited,This mechanism allows developers to attach custom logic that will be executed at these points, enabling better resource management and cleanup operations.
It is used inside plugin function to release resources.
The following example shows how to register a callback function:
Add_callback(vm, func(vm *Vm, idx int) {
// custom cleanup or finalization code
})