XLISP send

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

# send

Type: | - | function (subr)
Source: | - | xlobj.c

## Syntax

(send object message [args])
  object - an object
  message - message selector for object
  arg - parameter sent to object method
  returns - the object

## Description

The 'send' function is the mechanism used to send a 'message' to an object. The 'message' is the message selector symbol that is used to select a particular action [method] from the object.

## 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

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 send function in the XLISP 2.0 manual.

Back to Top

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