OxL Reference

1.5 Literals

KindSyntaxDefault type
Integer42, 1_000, 0xFF, 0o17, 0b1010, suffix 42u8inferred; otherwise i64
Floating-point3.14, 1e-9, 2.5f32inferred; otherwise f64
Booleantrue, falsebool
Character'a', '\n', '\u{1F600}'char
String"text {expr}"str
Raw stringr"C:\path", r#"..."#str
Multi-line"""…""" (the common indentation is removed)str
Bytesb"\x00abc"bytes
Duration250ms, 1h30m, 2d, 1.5sDuration
Size512B, 4KiB, 16MiB, 1GBu64 (bytes)
Date2026-11-03Date
Date-time2026-11-03T18:00, 2026-11-03T18:00:05.250LocalDateTime
UTC instant2026-11-03T15:00ZTime
Prefixedre"\d+", tz"Europe/Moscow", cron"0 9 * * MON-FRI", sha256"ab12…", ip"10.0.0.1"the handler's type
Absencenonenone
Unit()()

Rules:

  • Interpolation {expr} in a string evaluates expr and calls Show.show. A literal curly brace is {{ and }}. Format: {x:.2}, {x:08x}, {t:dd.MM.yyyy} (§17.5). The specifier {expression:spec}: spec = [[fill]align][sign][#][0][width][.precision][type]; alignment <, ^, > (numbers — >, text — <); sign + or -; # — the radix prefix (0x, 0o, 0b); 0 — zero padding (numbers only); .N — the number of fraction digits for floating-point values and the length (in characters) for text. Type: integers — x X o b; floating-point — e E; str, char — ? (quoted with escaping); Duration — a unit ns us ms s m h d: the value in these units followed by the suffix ({d:ms} → 1500ms, {d:.2s} → 1.50s); Time, LocalDateTime, Date — a pattern (§17.5); a type with a method fmt(spec: str) -> str — a custom format. A specifier that does not fit the type of the value is the compile error bad-format-spec; for types unknown at checking time (a generic parameter) only the syntax is checked (D-8064; D-7810).
  • Escape sequences: \n \r \t \\ \" \' \0 \xHH \u{H…}.
  • Duration units: ns us ms s m h d. A compound duration has the units in strictly descending order, without spaces (1h30m15s). Calendar intervals (months, years) are not literals but Period (§17.2).
  • Dates and date-times are recognised by the lexer greedily by the pattern DDDD-DD-DD[TDD:DD[:DD[.D+]]][Z]. Subtraction of numbers is written with spaces: 2026 - 11.
  • A prefixed literal p"…" calls the comptime function literal fn p(s: str) -> T from the scope (§15.3). An error in the handler is a compile error. Built-in prefixes: r b re tz cron sha256 ip url html.
  • An integer literal that does not fit the inferred type is a compile error.

bad-format-spec, invalid-char-literal, invalid-date, invalid-duration, invalid-escape, invalid-number, literal-overflow, unterminated-string

See also

Source: docs/spec/oxl-standard.en.md