XLISP :new

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

# :new

Type: | - | message selector
Source: | - | xlobj.c

## Syntax

(send class :new args)
  class - an existing XLISP class except for class
  args - the initializing arguments for the new instance
  returns - the new class object

(send class :new ivars [cvars [superclass]])
  ivars - list of instance variables for new class
  cvars - list of class variable symbols for new class
  superclass - superclass for new object, the default is object
  returns - the new class object

## Description

The ':new' message selector exhibits two different behaviors. When you are creating an instance of a class you only need the ':new' message [consisting of the message selector and any data]. When you are creating a new class with ':new', you need to specify instance variables and optionally the class variables and superclass.

## Examples

    (setq new-class (send class :new '(state)))      ; create NEW-CLASS with STATE
    (setq new-obj (send new-class :new))             ; create NEW-OBJ of NEW-CLASS
    (send new-obj :show)                             ; shows the object

    (setq sub-class (send class :new '(sub-state)    ; create SUB-CLASS of NEW-CLASS
                                     '() new-class))
    (send sub-class :show)                           ; show the SUB-CLASS

See the :new message selector in the XLISP 2.0 manual.

Back to Top

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