Language
Syntax
Tea uses `var` and `const`, block endings with `end`, backtick interpolation, and expression-friendly control flow.
Tea keeps the surface syntax small. Most files are built from a few recurring pieces: bindings, blocks that end with end, control flow, and strings with backtick interpolation.
This page focuses on how code is written, not on the full type system. If you are learning the language, these are the forms you will see first in everyday Tea programs.
Bindings, blocks, and if
Local values use const and var. Control-flow blocks start with a keyword such as if and always close with end.
const is_debug = true
var label = "tea"
if is_debug
label = "tea (debug)"
else
label = "tea"
end
const mode = if(is_debug) "verbose" else "normal"
@println(label)
@println(mode)Loops
Tea supports both while loops for condition-driven repetition and for ... in ... loops for iterating collections.
var count = 0
while count < 3
@println(count)
count = count + 1
end
const names = ["tea", "chai"]
for name in names
@println(name)
endWhen iterating dictionaries, you can bind both the key and value directly in the loop header.
const scores = {"tea": 10, "chai": 8}
for name, score in scores
@println(`${name}: ${score}`)
endStrings and interpolation
Use double quotes for ordinary strings and backticks when you want interpolation. Expressions inside a backtick string use ${...} placeholders.
var name = "Tea"
var version = 1
@println(`${name} v${version}`)Core syntax rules
- Blocks end with
end. - Use
constfor stable bindings andvarfor values you reassign. if(expr) a else bis supported as an expression.whileandfor ... in ...cover the core looping syntax.Backticks enable string interpolation with
${...}placeholders.