A document of lines
A smoot document is a list of lines. Each line is either a name for a value or a bare expression, and its answer appears beside it.
price = 50
tax = price * 8%
price + tax
Lines can come in any order. smoot works out what depends on what and evaluates the dependencies first, like a spreadsheet.
total = price + tax
price = 100
tax = 15
A name that refers to itself, directly or through other names, is an error: “refers to itself” for one line, “these lines depend on each other” for a loop through several.
Comments, headings, and notes
Section titled “Comments, headings, and notes”A line starting with # is a comment. // and -- work too. A line
starting with ## is a heading. /* ... */ comments out a span.
## Groceries
# the weekly shop
bread = 1.20 // per loaf
milk = 0.95 * 2 -- two pints
bread + milk
A line of plain English with no defined names in it is treated as a note and
ignored. A note that mentions a defined name, including a unit name, is read
as an expression and fails. When in doubt, start the line with #.
This line is a note and shows nothing.
# Safe: a comment can say anything, even 5 m of rope.
A name can be a whole phrase. Words with spaces are fine; smoot takes the longest name it knows.
coffees per week = 5
price per coffee = 4.50
weekly coffee spend = coffees per week * price per coffee
Names start with a letter or underscore and use letters, digits, and
underscores. Symbols and non-ASCII letters (π, °) are not allowed in
names; write pi and deg.
let marks a name as private. In a single document that changes nothing;
it matters only when a document is imported by another (see
Imports).
let deposit = 500
deposit * 2
Do not name a value after a unit you also use. A name shadows the unit
everywhere, so hours = 12.5 hours reads as hours = 12.5 * hours, and the
line reports that “hours” refers to itself. Write shift = 12.5 hours.
Declaring the same name twice is a warning; the later declaration wins.
Totals
Section titled “Totals”total adds up the lines since the previous total, back to the top of
the document for the first one. It adds the lines that are the same kind
as the line just above it: under a list of prices, a stray weight is
skipped. Name a total (subtotal = total) to use it later; a bare total
directly after another has nothing to add.
rent = 1350
food = 420
subtotal = total
travel = 85
total
If you name something total, the word means your value instead.