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

8. Predicates and Utilities

Now that we know how to create classes, access slots, and define methods, it might be useful to verify that everything is doing ok. To help with this a plethora of predicates have been created.

Function: class-v class
Return a vector with all the class's important parts in it. This vector is not a copy. Changing this vector changes the class. The CLOS method find-class will have the same effect.

Function: find-class symbol &optional errorp
CLOS function. In EIEIO it returns the vector definition of the class. If there is no class, nil is returned if errorp is nil.

Function: class-p class
Return non-nil if class is a class type.

Function: object-p obj
Return non-nil if obj is an object.

Function: slot-exists-p obj-or-class slot
Return Non-nil if obj-or-class contains slot in its class.

Function: slot-boundp object slot
Non-nil if OBJECT's SLOT is bound. Setting a slot's value makes it bound. Calling slot-makeunbound will make a slot unbound. OBJECT can be an instance or a class.

Function: class-name class
Return a string of the form #<class myclassname> which should look similar to other lisp objects like buffers and processes. Printing a class results only in a symbol.

Function: class-option class option
Return the value in CLASS of a given OPTION. For example:

(class-option eieio-default-superclass :documentation)

Will fetch the documentation string for eieio-default-superclass.

Function: class-constructor class
Return a symbol used as a constructor for class. This way you can make an object of a passed in class without knowing what it is. This is not a part of CLOS.

Function: object-name obj
Return a string of the form #<object-class myobjname> for obj. This should look like lisp symbols from other parts of emacs such as buffers and processes, and is shorter and cleaner than printing the object's vector. It is more useful to use object-print to get and object's print form, as this allows the object to add extra display information into the symbol.

Function: object-class obj
Returns the class symbol from obj.

Function: class-of obj
CLOS symbol which does the same thing as object-class

Function: object-class-fast obj
Same as object-class except this is a macro, and no type-checking is performed.

Function: object-class-name obj
Returns the symbol of obj's class.

Function: class-parents class
Returns the direct parents class of class. Returns nil if it is a superclass.

Function: class-parents-fast class
Just like class-parent except it is a macro and no type checking is performed.

Function: class-parent class
Deprecated function which returns the first parent of class.

Function: class-children class
Return the list of classes inheriting from class.

Function: class-children-fast class
Just like class-children, but with no checks.

Function: same-class-p obj class
Returns t if obj's class is the same as class.

Function: same-class-fast-p obj class
Same as same-class-p except this is a macro and no type checking is performed.

Function: object-of-class-p obj class
Returns t if obj inherits anything from class. This is different from same-class-p because it checks for inheritance.

Function: child-of-class-p child class
Returns t if child is a subclass of class.

Function: generic-p method-symbol
Returns t if method-symbol is a generic function, as opposed to a regular emacs list function.

It is also important to note, that for every created class, a two predicates are created for it. Thus in our example, the function data-object-p is created, and return t if passed an object of the appropriate type. Also, the function data-object-child-p is created which returns t if the object passed to it is of a type which inherits from data-object.

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

This document was generated by XEmacs Webmaster on August, 3 2012 using texi2html

Conform with <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html40/loose.dtd">
Automatically validated by PSGML