Skip to content

Externally Visible Functions

IsaacShelton edited this page Mar 21, 2022 · 1 revision

Externally Visible Functions

Functions can be made externally visible to other languages by using the external keyword before func

external func sum(a, b int) int {
    return a + b
}

Exported Symbols

By default, the exported symbol will be the cdecl mangled version of the function name. If this is undesired, the name of the exported symbol can be set to the cdecl mangled version of a custom export name, by specifying the exported symbol name after the func keyword.

external func "sum4i" sum4(a, b, c, d int) int {
    return sum(sum(a, b), sum(c, d))
}

In the above example, the function sum4 will exist within Adept source code, but will be referred to as sum4i outside of Adept source code. This allows for multiple exported functions to have to same name in Adept, while maintaining different symbol names so they can be accessed from other languages.

Clone this wiki locally