XLISP object

Nyquist / XLISP 2.0 - Contents | Tutorials | Examples | Reference

# object

Type: | - | object
Source: | - | xlobj.c

## Syntax

object

## Description

'object' is an object class. An object is a composite structure that contains internal state information, methods [which respond to messages], a pointer to the object's class and a pointer to the object's super-class. XLISP contains two built in objects: 'object' and class. 'object' is the superclass for the class object.

## Examples

    (send object :show)                                     ; look at the object definition

                                                            ; example use of objects
    (setq my-class (send class :new '(state)))              ; new class MY-CLASS with STATE

    (send my-class :answer :isnew '()                       ; set up initialization
                                  '((setq state nil) self))

    (send my-class :answer :set-it '(value)                 ; create :SET-IT message
                                   '((setq state value)))

    (setq my-obj (send my-class :new))                      ; create MY-OBJ out of MY-CLASS
    (send my-obj :set-it 5)                                 ; STATE is set to 5

Object definition: The internal definition of the 'object' object instance is:

    Object is #<Object: #23fd8>, Class is #<Object: #23fe2>
      MESSAGES = ((:SHOW . #<Subr-: #23db2>)
                  (:CLASS . #<Subr-: #23dee>)
                  (:ISNEW . #<Subr-: #23e2a>))
      IVARS = NIL
      CVARS = NIL
      CVALS = NIL
      SUPERCLASS = NIL
      IVARCNT = 0
      IVARTOTAL = 0
    #<Object: #23fd8>

The class of 'object' is class. There is no superclass of 'object'. Remember that the location information [like #23fd8] varies from system to system, yours will probably look different.

Built-in methods: The built in methods in XLISP include:

- :answer - add a method to an object
- :class - return the object's class
- :isnew - run initialization code on object
- :new - create a new object [instance or class]
- :show - show the internal state of the object

Message structure: The normal XLISP convention for a 'message' is to have a valid symbol preceeded by a colon like :isnew or ':my-message'. However, it is possible to define a 'message' that is a symbol without a colon, but this makes the code less readable.

See the object class in the XLISP 2.0 manual.

Back to Top

Nyquist / XLISP 2.0 - Contents | Tutorials | Examples | Reference