Skip to content

Instantly share code, notes, and snippets.

@zhouqiang-cl
Created December 14, 2016 07:27
Show Gist options
  • Save zhouqiang-cl/35038be5463d90b64e96770efbe958e1 to your computer and use it in GitHub Desktop.
Save zhouqiang-cl/35038be5463d90b64e96770efbe958e1 to your computer and use it in GitHub Desktop.
common lisp 的函数 CLASS-OF
语法
class-of object => class
参数和值
object --- 一个 object
class --- 一个 class object
描述
返回 object 的类, 其中object 是这个类的直接实例
代码
* (class-of 'fre)
#<BUILT-IN-CLASS SYMBOL>
* (class-of 2/3)
#<BUILT-IN-CLASS RATIO>
* (defclass book () ())
#<STANDARD-CLASS BOOK>
* (class-of (make-instance 'book))
#<STANDARD-CLASS BOOK>
* (defclass novel (book) ())
#<STANDARD-CLASS NOVEL>
* (class-of (make-instance 'novel))
#<STANDARD-CLASS NOVEL>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment