Language Reference
Functions
Package reusable logic into plain English function definitions.
Function patterns
- Use
create a function named. - Declare parameters with
takes. - Return values with
return.
Defining functions
Use does for multi-line bodies or returns for single-line functions.
functions.pln
create a function named add_numbers that takes two numbers and returns their sum
create a function named greet that takes name and does
print "Hello, " + name
return "Greeted " + name
Calling functions
Call functions with the call verb, direct parentheses, or dot-style calls without parentheses.
calls.pln
call greet with "Ada"
greet with "Ada"
set total to add_numbers(4, 6)
logging.error "Failed to connect"
print total
Function tips
- Keep function names verb focused:
calculate_total,format_report. - Use clear parameter names for readability.
- Return early for guard clauses and error checks.