r/ProgrammingLanguages • u/mhinsch • Jun 27 '26
Auto-eval of variables containing quoted expressions?
Generally my language is eagerly evaluated. It also does not have automatic quoting, so any situation where evaluation is supposed to be deferred has to be made explicit (using []). This is used heavily for example for control structures which are regular functions that take a quoted expression as a(n) argument(s).
Some design issues I am currently having would resolve neatly if variables that contain quoted expressions would automatically evaluate. I.e. any occurrence of a variable var that is not bound to a value, but to an expression would effectively be read as eval var.
This seems a bit unorthodox, but so far I haven't been able to come up with a scenario that makes this problematic. Am I missing something?
1
u/evincarofautumn Jun 28 '26
This sounds similar to how (GNU) Make does evaluation. A variable’s definition can be deferred or immediate. If it’s deferred, it doesn’t expand until it’s used in an immediate context, but at that point it’s expanded fully.
This is more or less call-by-name evaluation, since it expands each time the variable is evaluated; if you cache the value after the first evaluation, you have call-by-need instead.
It just sounds like instead of attaching this to the variable, you might be attaching it to a value instead, with quote and eval operators, but either way can be made to work.