[ < ] [ > ]   [ << ] [ 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 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