[Rd] A delayedAssign() variant for quoted expressions
Taras Zakharko
t@r@@@z@kh@rko @end|ng |rom uzh@ch
Fri Feb 10 17:00:44 CET 2023
It is sometimes useful to create a promise using a constructed expression, but delayedAssign will always substitute the expression argument. I am currently using this pattern to achieve this:
expr <- bquote(…)
eval(call("delayedAssign", x, expr, eval.env = eval_env))
But it would be nice if base R already had a function that takes quoted promise body. It could be named delayedAssign0 or delayedAssignq (similar to evalq). The definition of such function would be trivial (just remove substitute from delayedAssign):
function (x, value, eval.env = parent.frame(1), assign.env = parent.frame(1)) .Internal(delayedAssign(x, substitute(value), eval.env, assign.env))
Maybe R maintainers could consider adding this function? I would be happy to submit a patch.
Best,
Taras
[[alternative HTML version deleted]]
More information about the R-devel
mailing list