metaclass
1. It's remarkable enough when implementations of simple techniques work exactly as expected the first time; but my first metaclass hack in a new language, six days from a cold standing start?
32行代码,还包括注释行,就出现了我所想要的那个类的结构,调用的代码也很容易读。
2. For the implementation of respondsTo() a method is passed to a metaclass constructor as a triple selector/tag/method.
respondTo()的实现是传入一个选择器、标记、方法组成的三元组作为元类构造函数的参数。
3. If we add dynamically linked methods such as draw(), we need to start a new metaclass, because its constructor is the one to insert the method address into a class description.
一个元类构造函数充当起类描述因而实现二元继承,析构函数返回0值以使类描述免于销毁,显示函数能够表示方法指针,等等。
4. A few operations may be viewed as characterizing a class rather than its instances, justifying their inclusion as features of a metaclass.
一些运算也许被看成是类的特征,而不是类的实例,它们的内容也证实为一个元类的特性。
5. Once we intro?duce metaclasses, we can finally declare the selector for a dynamically linked method where it belongs: in the same interface file as the metaclass pointer.
一旦引入元类,我们终于能在元类指针所在的同一接口头文件里声明动态连接方法专有的选择器。
6. Things remain finite because we start with a trivial class Object and with a first metaclass Class which has Object as a superclass.
从一个最简约的类'''Object'''和元类'''Class'''(前者为后者的基类)出发,现在的局面还不是太复杂。
7. metaclass programming
元类程序设计
8. Class descriptions with the same set of methods are the objects of a metaclass.
同一组方法的类描述就是元类的对象。
9. A metaclass, again, has a class description.
同样地,一个元类也有类描述。
10. Oh, and because metaclasses are inherited so you can provide a base-class that uses your metaclass and sub-classes inherit it without explicitly having to declare it.
哦,还有因为元类是继承的,所以你能够提供一个使用了你的元类的基类,而继承自它的子类就无需显式声明它了。
11. A metaclass as such is a class and, therefore, has a class description.
如此一个元类也是一个类,因此有自己的类描述。
12. Each metaclass specification was expanded with information that explicitly identifies semantic variation points, notational options, and its relationship to the UML 1 specifications.
每一个元类规范被扩大化了,它明确地确定了语义的不同点,符号的选择权,以及它与UML 1规范的关系。
13. There is a standard way to write all metaclass constructors so that the selector/method pairs can be specified in any order.
这是写所有元类构造函数的标准方试,这样就可以以任意次序指定选择器/方法对偶。
14. More classes in the same metaclass can be created just by sending new() to the metaclass description.
通过传送'''new()'''方法给元类描述,就可以创建该元类下更多别的类。
15. In practice, then, we can do without a separate concept of metaclass.
那么,实际上不用一个单独的元类概念我们也能做到这一切。