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

5. Making New Objects

Once we have defined our classes, it's time to create objects with the specified structure. After we call defclass two new functions are created, one of which is classname. Thus, from the example at the end of the previous chapter See section 3. Building Classes, we would have the functions data-object and data-object-p.

Function: classname object-name &rest slots

This creates and returns a new object. This object is not assigned to anything, and will be garbage collected if not saved. This object will be given the string name object-name. There can be multiple objects of the same name, but the name slot provides a handy way to keep track of your objects. slots is just all the slots you wish to preset. Any slot set as such WILL NOT get it's default value, and any side effects from an attributes default function will not occur. An example pair would appear simply as :value 1. Of course you can do any valid lispy thing you want with it, such as :value (if (boundp 'special-symbol) special-symbol nil)

Example of creating an object from a class, 3. Building Classes:

 
(data-object "test" :value 3 :reference nil)


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

This document was generated by XEmacs shared group account on December, 19 2009 using texi2html 1.65.