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

self


Type:   -   symbol
Source:   -   xlobj.c

Syntax

 self

Description

The 'self' symbol evaluates to the current object when used within a message context.

Examples

(setq my-class (send class :new '(state)))               ; create MY-CLASS with STATE

(send my-class :answer :isnew '()                        ; set up initialization
                              '((setq state nil) SELF))  ;   returning 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 of MY-CLASS
(send my-obj :set-it 5)                                  ; STATE is set to 5

Context: 'self' does not exist except within the context of a method and it's execution.

Note: In the previous example, there is a 'self' in the line that creates the ':set-it' message. What this does is to return the object as the last operation when you do an :isnew.

See the self symbol in the XLISP 2.0 manual.

  Back to Top


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