Objective-C:为什么称它为'id'?

时间:2021-04-25 19:58:26

Why is the Objective-C object type called 'id'? As opposed to, say, 'object'?

为什么Objective-C对象类型称为“id”?而不是说“对象”?

5 个解决方案

#1


47  

It is called id because that, literally, is all the type represents - an identifier.

它被称为id,因为从字面上看,它是所有类型代表的 - 一个标识符。

Quoting Brad Cox from Object Oriented Programming: an Evolutionary Approach (actually, the first edition, one of the first OO books I bought): An id consumes a fixed amount of space, wide enough to identify as many objects as may exist at any one time. This space is not the same as the space occupied by the private data in the object itself. Object identifiers are fixed-sized numbers,...

从面向对象编程引用Brad Cox:一种进化方法(实际上,第一版,我购买的第一批OO书籍之一):id消耗固定数量的空间,宽度足以识别任何一个可能存在的对象时间。此空间与对象本身中私有数据占用的空间不同。对象标识符是固定大小的数字,......

#2


8  

I guess the other possibility not mentioned here would be that the Objective-C folks were Latin buffs and based it off the singular nominative/accusative (subject/object) forms of the Latin pronoun id (meaning "it"). It is sort of a generic word directed at a specific object, and id is a pointer to a generic object, so, you never know:).

我想这里没有提到的另一种可能性是,Objective-C人员是拉丁语爱好者,并以拉丁语代词id(意为“它”)的单数主格/指责(主语/宾语)形式为基础。它是一种针对特定对象的通用词,而id是指向通用对象的指针,所以,你永远不会知道:)。

#3


2  

Maybe it's the id of the class system (as in Freud's id/ego/superego) - that would make a bit of sense given the id is the basal nature of an organism. Not that I believe any of that Freud rubbish anyway :-).

也许它是阶级系统的id(如弗洛伊德的id / ego / superego) - 鉴于id是生物体的基本性质,这会有点意义。并不是说我相信任何弗洛伊德垃圾:-)。

Or, maybe the developers of Obj-C came from the UNIX school of namers (with "ls" or "cd") rather than the VAX school (with its "show directory" and "set directory").

或者,Obj-C的开发人员可能来自UNIX学校的名称(带有“ls”或“cd”),而不是VAX学校(带有“show directory”和“set directory”)。

Or, it could stand for instance data, which is probably more likely.

或者,它可以代表数据,这可能更有可能。

#4


2  

Theory without proof :

没有证据的理论:

How about 'identity' because it is a pointer to any unique object.

“身份”怎么样,因为它是指向任何唯一对象的指针。

#5


0  

As Ryan notes, it is actually a pointer: IIRC it is NSObject *.

正如Ryan所说,它实际上是一个指针:IIRC它是NSObject *。

As for the naming - maybe the namer uses a Dvorak key-layout. 'id' is really easy to type in that case (it's like typing 'gh' on Qwerty).

至于命名 - 也许名字使用Dvorak键布局。在这种情况下,'id'很容易输入(就像在Qwerty上键入'gh')。

#1


47  

It is called id because that, literally, is all the type represents - an identifier.

它被称为id,因为从字面上看,它是所有类型代表的 - 一个标识符。

Quoting Brad Cox from Object Oriented Programming: an Evolutionary Approach (actually, the first edition, one of the first OO books I bought): An id consumes a fixed amount of space, wide enough to identify as many objects as may exist at any one time. This space is not the same as the space occupied by the private data in the object itself. Object identifiers are fixed-sized numbers,...

从面向对象编程引用Brad Cox:一种进化方法(实际上,第一版,我购买的第一批OO书籍之一):id消耗固定数量的空间,宽度足以识别任何一个可能存在的对象时间。此空间与对象本身中私有数据占用的空间不同。对象标识符是固定大小的数字,......

#2


8  

I guess the other possibility not mentioned here would be that the Objective-C folks were Latin buffs and based it off the singular nominative/accusative (subject/object) forms of the Latin pronoun id (meaning "it"). It is sort of a generic word directed at a specific object, and id is a pointer to a generic object, so, you never know:).

我想这里没有提到的另一种可能性是,Objective-C人员是拉丁语爱好者,并以拉丁语代词id(意为“它”)的单数主格/指责(主语/宾语)形式为基础。它是一种针对特定对象的通用词,而id是指向通用对象的指针,所以,你永远不会知道:)。

#3


2  

Maybe it's the id of the class system (as in Freud's id/ego/superego) - that would make a bit of sense given the id is the basal nature of an organism. Not that I believe any of that Freud rubbish anyway :-).

也许它是阶级系统的id(如弗洛伊德的id / ego / superego) - 鉴于id是生物体的基本性质,这会有点意义。并不是说我相信任何弗洛伊德垃圾:-)。

Or, maybe the developers of Obj-C came from the UNIX school of namers (with "ls" or "cd") rather than the VAX school (with its "show directory" and "set directory").

或者,Obj-C的开发人员可能来自UNIX学校的名称(带有“ls”或“cd”),而不是VAX学校(带有“show directory”和“set directory”)。

Or, it could stand for instance data, which is probably more likely.

或者,它可以代表数据,这可能更有可能。

#4


2  

Theory without proof :

没有证据的理论:

How about 'identity' because it is a pointer to any unique object.

“身份”怎么样,因为它是指向任何唯一对象的指针。

#5


0  

As Ryan notes, it is actually a pointer: IIRC it is NSObject *.

正如Ryan所说,它实际上是一个指针:IIRC它是NSObject *。

As for the naming - maybe the namer uses a Dvorak key-layout. 'id' is really easy to type in that case (it's like typing 'gh' on Qwerty).

至于命名 - 也许名字使用Dvorak键布局。在这种情况下,'id'很容易输入(就像在Qwerty上键入'gh')。