3. Primitive types and literals
Numbers with width suffixes, strings and heredocs, symbols, and booleans.
After this lesson you can
- Pin a number's exact type with a width suffix - Write multi-line text with a heredoc - Use symbols for enum-like tagged values
Before you start: Fields, blocks, and comments
WCL's numbers are fixed-width: signed i8–i128, unsigned u8–u128, floats f32/f64, plus platform-sized isize/usize. A bare integer defaults to i64; a suffix like 200u8 pins the exact type, and underscores may group digits (1_000_000u32).
Strings are UTF-8. A quoted literal handles one line; a heredoc (<<END … END) keeps line breaks for multi-line text, and the $"..." form interpolates expressions. Symbols are identifier-like values written :name — use them where you'd otherwise reach for a magic string.
§ 1Exercise: One of everything
Write a document exercising each primitive literal form, then evaluate the heredoc field.
@document
type Doc {
small: u8
big: i64
ratio: f64
grouped: u32
greeting: utf8
banner: utf8
shade: symbol
ok: bool
}
small = 200u8
big = -42
ratio = 2.5
grouped = 1_000_000u32
greeting = "hello"
banner = <<END
Multi-line text keeps
its line breaks.
END
shade = :amber
ok = true
Expected result
wcl check prints OK, and wcl eval doc.wcl banner prints the two-line string with an embedded \n.
Hint
Try small = 300u8 — the check fails because 300 doesn't fit in a u8. Width suffixes are real constraints, not annotations.