Module constants (let at the top level) and imprint values are computed without any
effects, so their initializers must be pure. Reading files, the clock or randomness happens in
a function that declares the effect.
Wrong#
let START = time.now()
fn main() { print(START) }Fixed#
fn main() uses time {
let start = time.now()
print(start)
}Common causes#
- Loading configuration into a global: load it in
mainand pass it along. imprintcomputed from a file: embed the data as a literal instead.