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?
View all comments
Show parent comment
2
u/mhinsch Jun 28 '26
Hmm, all good points, but I think the worst one I just realised is that by default quoted expressions that are returned by a function will always be evaluated (since only explicit quoting prevent evaluation). To prevent that I would have to either introduce a construct that basically means 'evaluate expression but quote return value', special case function returns, or require double quoting for returns. None of these options are particularly attractive.