Common Lisp中的标准对象和标准类的层次结构 [英] Hierarchy of standard-object and standard-class in Common Lisp

查看:109
本文介绍了Common Lisp中的标准对象和标准类的层次结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究Common Lisp(与Lispworks),并且现在正在尝试进入课堂系统.有一个名为 standard-object 的类,它定义为

I'm studying Common Lisp (with Lispworks) and I'm trying to get into class system right now. There is a class called standard-object and it is defined as

standard-object standard-class 的一个实例,并且是每个作为 standard-class 的实例的类的超类. >本身除外.

The class standard-object is an instance of standard-class and is a superclass of every class that is an instance of standard-class except itself.

(取自 http://www.lispworks.com/documentation/HyperSpec/正文/t_std_ob.htm#standard-object ) 因此它是标准类

另一方面, standard-class standard-object

>(subtypep 'standard-class 'standard-object)
=>T, T

标准对象如何成为标准类的超类并同时成为其实例?如果我们将标准类定义为子类型,则应在其超类定义后 定义它(例如,标准对象),那么,超类怎么可能成为实例呢?还是我的逻辑是错误的?

How can the standard-object be a superclass for the standard-class and be its instance at the same time? If we define standard-class as a subtype, we should define it after defenition of its supertype (e.g. standard-object), so how can it be, that the superclass becomes the instance? Or my logic is just wrong?

推荐答案

CLOS是一个对象系统,其中CLOS概念本身是一流的对象.类本身是元类的实例.涉及到一些循环性.

CLOS is an object system, where CLOS concepts itself are first-class objects. Classes themselves are instances - of a meta class. There is some circularity involved.

有一个实例standard-object.这是standard-class的实例.它本身就是一个类.所有标准CLOS对象都将其作为超类.还有其他类型的对象,例如结构.因此,standard-object作为所有典型CLOS对象的超类都存在.

There is an instance standard-object. It's an instance of standard-class. It is a class itself. All standard CLOS objects will have it as a superclass. There are other types of objects, for example structures. So standard-object is there as a superclass for all typical CLOS objects.

standard-class是其自身的实例.它是所有类对象的类.因为standard-object也是一个类,所以类standard-object的实例是类standard-class的实例.由于所有标准类也是CLOS对象,因此standard-class继承自standard-object.

standard-class is in instance of itself. It is the class of all class objects. Since standard-object is also a class, the instance for the class standard-object is an instance of the class standard-class. Since all standard classes are also CLOS objects, standard-class inherits from standard-object.

CL-USER 22 > (class-of (find-class 'standard-object))
#<STANDARD-CLASS STANDARD-CLASS 40F016A063>

standard-object类对象的类是standard-class.

CL-USER 23 > (class-of (find-class 'standard-class))
#<STANDARD-CLASS STANDARD-CLASS 40F016A063>

standard-class类对象的类是standard-class.

CL-USER 24 > (find-class 'standard-object)
#<STANDARD-CLASS STANDARD-OBJECT 40F017732B>

standard-object本身是一个对象和一个类.它是所有CLOS对象的超类.

The class standard-object is itself an object and a class. It is a superclass of all CLOS objects.

CL-USER 25 > (find-class 'standard-class)
#<STANDARD-CLASS STANDARD-CLASS 40F016A063>

standard-class本身是一个对象和一个类.它是所有CLOS类的超类.

The class standard-class is itself an object and a class. It is a superclass of all CLOS classes.

这篇关于Common Lisp中的标准对象和标准类的层次结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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