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


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


(putprop symbol value property)
symbol - the symbol with a property list
value - the value to be assigned to the property
property - the property name being changed or added
returns - the property value


The 'putprop' function sets the value of the 'property' in the 'symbol'. If the 'property' does not exist, the 'property' is added to the property list. The 'symbol' must be an existing symbol. The 'value' may be a single value or a list.

Property lists are lists attached to any user defined variables. The lists are in the form of:

(name1 val1 name2 val2 ... )

Any number of properties may be attached to a single variable.


(setq person 'bobby)                  ; create a var with a value
(putprop person 'boogie 'last-name)   ; add a LAST-NAME property
(putprop person 'disc-jockey 'job)    ; add a JOB property

(get person 'last-name)               ; retrieve LAST-NAME - boogie
(get person 'job)                     ; retrieve JOB - disc-jockey
(get person 'height)                  ; non-existant - returns NIL

(putprop person '(10 20 30) 'stats)   ; add STATS - a list
(get person 'stats)                   ; retrieve STATS - (10 20 30)

Note: You can set a property to the value NIL. However, this NIL value is indistinguishable from the NIL returned when a property does not exist.

Common Lisp: Common LISP does not have a 'putprop' function. It uses setf to achieve this functionality. Porting from Common Lisp to XLISP will work fine since XLISP supports the setf modifications of property lists as well as the get function to retrieve property values from symbol names. Porting from XLISP to Common Lisp will require translating 'putprop' into setf forms.

Caution: In XLISP, the order of 'putprop' arguments is 'symbol', 'value', 'property'. This is different from many other Lisps which normally use 'symbol', 'property', 'value'. Be careful when porting existing Lisp code.

See the putprop function in the XLISP 2.0 manual.

  Back to Top

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