06 · Functions
External argument labels
Separate a public call label from the local parameter name: from source: int. The caller uses from:, while the function reads source. Labels are part of callable interfaces and remain available when passing a function as a value.
On this page
Separate a public call label from the local parameter name: from source: int. The caller uses from:, while the function reads source. Labels are part of callable interfaces and remain available when passing a function as a value.
Complete example
External argument labels.
23-external-argument-labels.zolo
// expected: 12
// expected: 3
// expected: 15
// expected: 9
// expected: 18
// expected: 2
fn travel(from source: int, to destination: int, by step: int = 1) -> int =
(destination - source) * step
let from = 2
let to = 8
print(travel(to:, from:, by: 2))
print(travel(1, 4))
fn choose(with transform: fn(int) -> int, on value: int) -> int = transform(value)
print(choose(on: 5, with: |value| value * 3))
fn dialog(confirm action: fn() -> int, title heading: str = "Ready") -> int =
action() + heading.len()
print(dialog(title: "Go") confirm { 7 })
fn double(value: int) -> int = value * 2
let labelled: fn(input: int) -> int = double
print(labelled(input: 9))
fn advance(from start: int, to finish: int = start + 2) -> int = finish - start
print(advance(from: 4))
Rules and behavior
Function parameters and lambdas · Documentation
From a checkout of the repository:
zolo examples/features/05-functions/23-external-argument-labels.zolo
See also