Syntax & Comments
Use indentation for structure and comments for intent.
AAL uses indentation to delimit blocks. Here, if belongs to the ability and return belongs to its branch. A comment begins with # and does not execute.
Complete example
Save the example as syntax.aal
agent Tutorial is Agent
public
ability run(name: String) -> String effects()
# Return early when the name is empty.
if name == ""
return "Hello!"
return "Hello, {name}!"Syntax explained
-
Indent with spaces, not tabs. Keep sibling statements aligned; these examples use two spaces per level.
-
A colon at a block header is optional; this tutorial consistently omits it.
-
Calls, lists and records may span lines within delimiters. Strings use double quotes.
Build and run
cargo run --locked --bin aalc -- check syntax.aal
cargo run --locked --bin aalc -- build syntax.aal -o syntax.aalc
cargo run --locked --bin aalc -- run syntax.aalc \
--agent Tutorial --ability run \
--args '{"name":""}' \
--state-dir .aal-tutorial/syntax --invocation syntax-1Run with a fresh state directory. The returned value is shown below; the CLI also prints execution information.
"Hello!"Try it yourself
Change the empty name to EasyNet and use a new invocation ID. The first return is skipped and the result becomes Hello, EasyNet!.