{rlang} 的 'curly-curly' 运算符 `{{` 是如何实现的?

How is {rlang}'s 'curly-curly' operator `{{` implemented?

help("nse-force"){rlang} 文档给出了以下内容:

The curly-curly operator {{ }} for function arguments is a bit special because it forces the function argument and immediately defuses it. The defused expression is substituted in place, ready to be evaluated in another context, such as the data frame.

我同样对 'bang-bang' 运算符 !! 感到困惑,关于它的文档对于幕后发生的事情同样晦涩难懂。

我的问题不是关于如何 使用 运算符,因为它的用法(我认为)非常简单。相反,我想知道 {rlang} 在幕后如何实际实施这样的运算符。根据package authors之一,{{ foo }}基本上变成了!!rlang::enquo(foo)。然而,我仍然无法理解像这样的非标准运算符实际上是如何 实现的 ,特别是考虑到这个似乎 'just work', 不管它是否被 {rlang} 函数使用。 实际上它 与 {rlang} 支持的函数一起工作 - 感谢@Konrad Rudolph 的更正。

查看 the source code 我只能猜测它是用 C 或 C++ 完成的。谁能给我更多信息?

However I'm still at a loss to understand how non-standard operators like this are actually implemented, especially considering that this one seems to 'just work', regardless of whether it's being used by {rlang} functions.

对任意函数“有效”——相反:函数do需要注意整洁的评估.正如您可能猜到的那样,没有 {{ 运算符。相反,“rlang”使用 NSE 来捕获未评估的参数,然后检查表达式的解析树是否包含两个嵌套的 { 调用。然后它采用未计算的表达式并适当地转换它。