[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.2 General Inquiry

Function: class-of obj

Returns a class metaobject of obj.

 
(class-of 3)         ⇒ #<class <integer>>
(class-of "foo")     ⇒ #<class <string>>
(class-of <integer>) ⇒ #<class <class>>
Function: is-a? obj class

Returns true if obj is an instance of class or an instance of descendants of class.

 
(is-a? 3 <integer>)   ⇒ #t
(is-a? 3 <real>)      ⇒ #t
(is-a? 5+3i <real>)   ⇒ #f
(is-a? :foo <symbol>) ⇒ #f

If obj's class has been redefined, these procedures first updates obj to change its class to the new class. So class-of always returns the new class. This behavior is different from stklos 0.55, in which class-of returns an old class if obj hasn't been updated. If you need to get the old class, you should use current-class-of below. See Class redefinition for the details of the semantics of redefined class.

Function: current-class-of obj

Returns a class metaobject of obj. If obj's class has been redefined, but obj is not updated for the change, then this procedure returns the original class of obj without updating obj.

You need this procedure in rare occasions, such as within change-class method, in which you don't want to trigger updating obj (which would cause infinite loop).


[ < ] [ > ]   [ << ] [ Up ] [ >> ]

This document was generated by Shiro Kawai on October, 7 2008 using texi2html 1.78.