duql now(): read once per compile, fold to a constant, no injection API
DecisionVerified 2 Oct 2026Holds anywhere
Decision. The context, the choice, why, and the options that were turned down.
Context#
Implementing now() in duql (E6).
Decision#
now() is handled by name like as_time (builtin_name, time_call), reads system_clock once per compile cached in Lowering::now_, floors to the time role unit, folds to a constant, and unit_of(now()) is the time unit so ts > now() - 1h works.
Why#
One read per compile keeps a query's timestamps consistent and the constant fold keeps it cheap.
Rejected options#
A reserved parameter or env var for injection — no injection API: tests bound it between two clock reads.
Also found by searching
- now() handled by name like as_time
- reads system_clock once per compile cached in Lowering::now_
- unit_of(now()) is the time unit so ts > now() - 1h works
- no injection API, tests bound between two clock reads