Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Functions

Aranya Policy Language can define functions (see Function Declarations), which can be called inside an expression in the usual way.

function increment(x int) int {
    return x + 1
}

function increment_twice(x int) int {
    return increment(increment(x))
}

Functions cannot be called recursively, and any attempt to do so are a compiler error.

FFI functions can be called similarly, but must be specified with their library name.

use math

function increment_twice(x int) int {
    return math::add(x, 2)
}

In addition to these functions, there are operator-like internal functions that work similarly, described in the next subsections.