String formatting
String literals are plain and simple — no embedded expression syntax. To build a string out of variables without a long chain of +, use format(template, ...args): it replaces each {} in template, left to right, with the matching argument converted to text the same way str() would.
ton.string name = "kuro"
ton.int age = 5
print(format("Hello {}, you'll be {} next year!", name, age + 1))
// Hello kuro, you'll be 6 next year!
An argument can be any value — a number, a string, the result of a function call, anything str() can convert. Extra {} placeholders with no matching argument are left as-is ({}); extra arguments beyond the number of placeholders are simply unused.
f-strings (since beta-2.0.0) — prefix a string with f to embed any expression between braces. It's the shortest way to build text out of values; format() keeps working.
ton.string name = "kuro"
ton.int age = 21
print(f"Hello {name}, next year you'll be {age + 1}!")
print(f"{len(name)} letters, upper: {name.upper()}")
print(f"Braces: {{like this}}") // {{ and }} are literal braces
Raw strings — backticks delimit a string with no escape sequences, which can span several lines. Handy for HTML, regular expressions and Windows paths:
ton.html page = `<div class="card">
<p>C:\temp\new is not a newline here</p>
</div>`
Escapes in double-quoted strings: \n \t \r \" \\ \0, and \u{1F680} / \u00e9 for any Unicode character (written as UTF-8).
Formatting numbers: fixed(3.14159, 2) gives "3.14", "7".padStart(3, "0") gives "007".