XLISP > XLISP 2.0  -  Contents  -  Reference  -  Previous | Next

class


Type:   -   object
Source:   -   xlobj.c

Syntax

 class

Description

'class' is the built-in object class that is used to build other classes. Classes are, essentially, the template for defining object instances.

Examples

(setq myclass (send class :new '(var)))              ; create MYCLASS with VAR

(send myclass :answer :isnew '()                     ; set up initialization
                             '((setq var nil) self))

(send myclass :answer :set-it '(value)               ; create :SET-IT message
                              '((setq var value)))    

(setq my-obj (send myclass :new))                    ; create MY-OBJ of MYCLASS
(send my-obj :set-it 5)                              ; VAR is set to 5

Class definition: The internal definition of the 'class' object instance looks like:

Object is #<Object: #23fe2>, Class is #<Object: #23fe2>
  MESSAGES = ((:ANSWER . #<Subr-: #23e48>) 
              (:ISNEW . #<Subr-: #23e84>) 
              (:NEW . #<Subr-: #23ea2>))
  IVARS = (MESSAGES IVARS CVARS CVALS SUPERCLASS IVARCNT IVARTOTAL)
  CVARS = NIL
  CVALS = NIL
  SUPERCLASS = #<Object: #23fd8>
  IVARCNT = 7
  IVARTOTAL = 7
#<Object: #23fe2>

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

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

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 class object in the XLISP 2.0 manual.

  Back to Top


XLISP > XLISP 2.0  -  Contents  -  Reference  -  Previous | Next