为什么data.table定义了:=而不是重载< - ? [英] Why has data.table defined := rather than overloading &lt;-?

查看:107
本文介绍了为什么data.table定义了:=而不是重载< - ?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

data.table已经引入了:=运算符。为什么不重载< - ?

data.table has introduced the := operator. Why not overload <-?

推荐答案

我认为没有任何技术原因,原因::= 仅在 [...] 内使用,因此始终使用引号。 [...] 通过表达式树查看:= 是否在其中。

I don't think there is any technical reason this should be necessary, for the following reason: := is only used inside [...] so it is always quoted. [...] goes through the expression tree to see if := is in it.

这意味着它不是真正的作为一个运算符,它不是真的重载;所以他们可以选择几乎任何他们想要的操作员。我想也许它看起来更好?或者较少混淆,因为它显然不是< -

That means it's not really acting as an operator and it's not really overloaded; so they could have picked pretty much any operator they wanted. I guess maybe it looked better? Or less confusing because it's clearly not <-?

= c 之外 使用 ,因为您实际上不能重载 < - t评估其左边的参数,所以它不知道什么类型是)。

(Note that if := were used outside of [...] it could not be <-, because you can't actually overload <-. <- Doesn't evaluate its lefthand argument so it doesn't know what the type is).

这篇关于为什么data.table定义了:=而不是重载< - ?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆