在包函数中使用 bang-bang (!!) 和 walrus (:=) 的最佳实践

best practices for using bang-bang (!!) and walrus (:=) inside package functions

编写新包时的最佳做法是使用 package::function() 语法调用其他包函数并保持名称空间干净。当我在包的函数中使用它们时,告诉 R 使用 rlang 的 !!:= 的等效操作是什么,因为它们没有函数形式?使用 load_all() 似乎工作正常,但我想确保它们不只是工作,因为其他东西已经将 rlang 加载到我的路径中。

他们不需要导入:

From Advanced R

. !! and !!! behave specially inside all quoting functions powered by rlang, where they behave like real operators with precedence equivalent to unary + and -. This requires considerable work inside rlang, but means that you can write !!x + !!y instead of (!!x) + (!!y).

来自

Once an rlang function detects this "operator" it treats it differently to perform the tidy evaluation necessary (which is why the operator is only useful in a rlang context) ... This is why you only need to import the rlang function you want, because the logic for dealing with !! lies inside rlang internals, not a separate function