Skip to content

Language Basics

Chloë Strainge edited this page Oct 15, 2026 · 2 revisions

Language basics

A Shelly program is a sequence of statements. Newlines and semicolons separate them. Braces group statements into a scope or the body of another construct.

Words, strings, and calls

fn label($word: String): String { "label=" + $word }
echo (label notebook)
let $literal = "notebook"
echo $literal
label=notebook
notebook

The word notebook is an argument in the first call. In let $x = notebook, it would instead be a command to execute. Double or single quotes make text explicit. Functions and calls describes each call context.

Comments and continuation

# starts a comment outside a string. A backslash followed by a newline joins source lines:

let $title = "Northern " \
    + "lights"
echo $title # This comment is not part of the String.
Northern lights

A header line #tab-size N is a tokenizer directive rather than an ordinary comment. It chooses tab stops for that source, with N from 1 through 32. Original tabs and string contents are preserved. This matters when drawing pipeline splits: \- starts a branch, and vertical | guides must continue its connection across intervening diagram rows.

Use spaces around arithmetic operators. This avoids confusing a path such as $root/file with division such as $root / $size.

Expressions and grouping

Expressions produce values. Parentheses group one expression or request a nested call; they do not contain a semicolon-separated mini-program. Functions, if, and match can produce values from blocks. A standalone block is a statement scope.

() is the unit/no-value literal. It is useful for omitted values, optional types, and iterator termination. It is not an empty function argument list: do_work () passes one unit argument; do_work supplies no arguments.

Capitalization and names

Variables use $name or ${name}. Type names are case-sensitive: Integer and integer are different names. any is the lowercase universal type constraint. Module qualification uses ::, as in tools::run and $tools::setting.

Common punctuation has a dedicated page in the syntax reference. The language's call rules apply to keywords used as arguments too: echo let prints the word let.


Related: Variables and scope · Strings and paths

Clone this wiki locally