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


Type:   -   function (subr)
Source:   -   xlbfun.c


(set symbol expr)
symbol - expression that evaluates to a symbol name [if the expression is quoted, no evaluation occurs]
expr - an expression, which will be the new value
returns - the new value


The 'set' function evaluates 'symbol' and sets 'expr' as it's value. If the 'symbol' value is quoted via the quote special form or read-macro expansion, the 'symbol' is not evaluated. 'set' returns the value from 'expr' as it's result.


(set 'a 2)            ; sets symbol A to value 2
(set 'value a)        ; sets symbol VALUE to value 2
(print value)         ; show the value - prints 2

(set 'name 'myvar)    ; set symbol NAME to value MYVAR
(set name 12345)      ; set symbol which is the value
                      ;   of NAME (MYVAR) to 12345

(print name)          ; prints MYVAR
(print myvar)         ; prints 12345

(set notsymbol 1)     ; error: unbound variable
(set name notvalue)   ; error: unbound variable

See the set function in the XLISP 2.0 manual.

  Back to Top

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