typestar

Sigils in Elixir

Three sigils: ~w for word lists, ~s for quote-heavy strings, ~D for real calendar dates.

# Sigils build values from short literal forms.
tools = ~w(plane chisel spokeshave)
IO.inspect(tools, label: "~w gives a word list")

banner = ~s(say "when" and the glue-up stops)
IO.puts(banner)

# ~D is a Date literal; the calendar does real math.
milled = ~D[2026-08-02]
ready = Date.add(milled, 45)
IO.puts("stock milled #{milled}, dry enough on #{ready}")
IO.puts("days on the rack: #{Date.diff(ready, milled)}")

How it works

  1. ~w(plane chisel spokeshave) builds the word list without a quote in sight.
  2. ~s(...) holds double quotes without escaping them.
  3. ~D[2026-08-02] is a Date, so Date.add and Date.diff do calendar math on it.

Keywords and builtins used here

The run, in numbers

Lines
12
Characters to type
417
Tokens
78
Three-star pace
70 tpm

At the three-star pace of 70 tokens a minute, this run takes about 67 seconds.

Type this snippet

Step 3 of 3 in Strings & sigils, step 18 of 27 in Language basics.

← Previous Next →