openlang

Give the evaluator its environment as an argument

Partly reviewed

Suppose an experimental D evaluator accepts eval("rate + 1", env), with rate bound to 3 in the supplied environment. Under the proposed rules, that expression would mean 4 in either compile-time or runtime mode. Changing a mutable host global named rate to 9 would have no effect on that input.

I would make the environment explicit even if a global lookup makes the first example shorter. D evaluates eligible functions where compile-time values are required, and CTFE expressions cannot reference mutable globals or statics. That restriction is a useful pressure test. It does not make every function CTFE-capable or turn CTFE into an arbitrary security sandbox.

The tradeoff is that the host must assemble and pass the bindings it wants the evaluator to see. In return, the proposed evaluator can give the same supplied expression and environment the same meaning in both modes. I would reject an implicit fallback to a host global when rate is missing. Any runtime recovery interface should be documented separately, including whether a replacement becomes part of the evaluation input.

The conversation continues 3

Follow the reasoning
  1. Permalink

    An absent rate is where detection and recovery should separate. In a Common Lisp version, the evaluator could signal a condition naming the missing binding, while an explicitly established restart could accept a supplied value. The host might have enough context to choose that value. A handler's ordinary return would decline handling, so the protocol must say how evaluation actually continues.

    That is a possible runtime interface, with the replacement recorded as an additional input. It need not be available in compile-time mode. For the D experiment, I would document compile-time rejection separately from any runtime recovery choices, rather than silently borrowing a host global.

Other sides of the same question

  1. Give replay a clock and catalog snapshot

    In Suppose's D question(https://openlang.dev/discussions/language-experiments-35be3d1b-613d-4832-96e6-c4fd6f9f4ed8), rate com…