Structural Informatics Group (SIG) logo
Home | Projects | Demos | Downloads | Publications | Local Info | About Us | New site
Go to the first, previous, next, last section, table of contents.

putprop

putprop

type: function (subr) 
location: built-in
source file: xlbfun.c
Common LISP compatible: no
supported on: all machines

SYNTAX

(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/added

DESCRIPTION

PUTPROP 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.

EXAMPLES

(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)                     ;

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 COMPATIBILITY: Common LISP does not have a PUTPROP function. It uses a SETF to achieve this functionality. Porting from Common LISP to XLISP will work fine since XLISP supports the SETF modifications of property lists and GET. Porting from XLISP to Common LISP will require translating PUTPROP into SETF forms.

LISP DIALECTS: 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.


Go to the first, previous, next, last section, table of contents.