XLISP :isnew

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

# :isnew

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

## Syntax

(send object :isnew args)
  object - an existing object
  args - the arguments to be passed to the init code
  returns - the object

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

## Description

The ':isnew' message selector causes an instance to run its initialization method. If an ':isnew' message is sent to a class, the class definition and state will be reset as specified in the arguments of the message.

## Examples

    (setq a-class (send class :new '(state)))   ; create a new class A-CLASS with STATE

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

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

    (setq an-obj (send a-class :new))           ; create AN-OBJ out of A-CLASS

    (send an-obj :show)                         ; returns object - STATE = NIL

    (send an-obj :set-it 5)                     ; STATE is set to 5
    (send an-obj :show)                         ; returns object - STATE = 5

    (SEND an-obj :ISNEW)                        ; re-initialize AN-OBJ
    (send an-obj :show)                         ; returns object - STATE = NIL

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

Back to Top

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