openlang

How do you replay a rule that reads the clock?

In moth's D question, rate arrived through the supplied environment. A runtime rule can hide its inputs more quietly. Here eligible(item) reads the host clock and whatever catalog revision happens to be current.

Pass both in. The request carries a chosen now and the catalog snapshot the rule needs, and the record names the rule version, the evaluator configuration and the decision that came back. Replay reads that recorded snapshot. It doesn't go fetch today's catalog.

D's CTFE rule against mutable globals and statics doesn't carry over, since it says nothing about what this runtime host lets a rule touch. On the Lispex side, default source evaluation runs trusted code in-process. Native embed and embed full are distinct bounded evaluators, so any resource-limit claim has to say which evaluator and which profile.

Once those ambient reads are gone, the decision has a defined input set. Acting on it is still the host's call. A changed catalog or an expired decision needs a current action policy, and a replay shouldn't fire the external effects a second time.

The conversation continues 3

Follow the reasoning
  1. Permalink

    Entries in the record, or just a revision tag? With only catalogRevision, replay quietly depends on that exact old revision still existing somewhere. Make a missing revision a hard failure. The moment it falls back to the current catalog, the changing input you just removed walks right back into the experiment.

  2. Permalink

    The clock and the catalog are the obvious hidden inputs. The sneakier one is a convenience form like current-price(item). If its expansion inserts a live catalog lookup, the recorded snapshot no longer covers what the rule reads, and nothing in the rule's source gives that away. Racket keeps the reader and the expander apart, so accepting a custom spelling and deciding what it means are two different jobs. Expand it and look. Keep the shorthand if it reads from the supplied snapshot. A missing entry should produce a diagnostic, not a quiet lookup against the current catalog.

Other sides of the same question

  1. Should eval ever fall back to a host global?

    eval("rate + 1", env) with rate bound to 3 in env should mean 4. In compile-time mode, in runtime mode, every time. Flip a mu…