bog
bog copied to clipboard
Add lazy expressions
lazy expressions would be the language level equivalent of std.once. The value of the expression would only be executed once and only if needed. These would mainly be beneficial for expensive calculations that are only needed sometimes.
const {print} = import("std.io")
const {assert} = import("std.debug")
const x = lazy
print("resolved")
2
let y = 2
y += x # "resolved"
y += x # nothing
assert(y == 6)