为什么对象类型的名称与其所属类的名称不同? [英] Why is the name of an object type different from the name of the class it belongs to?

查看:62
本文介绍了为什么对象类型的名称与其所属类的名称不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在阅读 Chambers 的数据分析软件中的第 9 章,并且在第 337 页,他说:

I am currently reading Chapter 9 in Chambers' Software for Data Analysis, and on page 337, he says:

相比之下,类中的类有一些固有的限制contains= 参数.此处提供的类必须是:

In contrast, there are some inherent restrictions on the classe in the contains= argument. Classes supplied here must be either:

  1. ...
  2. 一种基本的 R 对象类型,但不是那些引用或非标准的类型;例如,不是 "environment" "symbol"(类"name"的对象类型).

重点是我的.

我天真的问题是,为什么对象类型的名称(symbol)与类名(name)不同?这与我将对象作为类的实例的理解相冲突.有没有其他这样的例子,我应该如何考虑这里的命名约定?

My naive question is, why is the name of the object type (symbol) different from the class name (name)? This clashes with my understanding of an object as an instance of a class. Are there any other such examples, and how should I think about the naming convention here?

推荐答案

我认为这会阻止您构建或要求其他级别的间接访问.可以假设解释器能够处理包含"规范中的预定义对象类型,但不能处理更灵活或需要查找传递给它的值中的内容的类型.符号"是一种寻找事物的方式,而不是事物"本身.

I see that as preventing you from constructing or requiring another level of indirection. The interpreter can assumed to be able to handle predefined object types in the 'contains' specification but not to be able to handle types that are more flexible or would require looking up what was in the value that was passed to it. A "symbol" is a way of finding something rather than the "something" itself.

R 除了模式"和类"之外,还有存储模式"和类型":

R has both "storage modes" and "types" in addition to "modes" and "classes":

> x=as.name('y')
> x
y
> mode(x)
[1] "name"
> class(x)
[1] "name"

> typeof(x)
[1] "symbol"
> storage.mode(x)
[1] "symbol"

这篇关于为什么对象类型的名称与其所属类的名称不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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