Previous: object-nickname, Up: Properties Dictionary


with-properties
— Macro: with-properties (property-entry*) object-form declaration* form*

=> result*

     property-entry ::= property-name | (variable-name porperty-name)

Arguments and Values:

property-name — a property name; not evaluated.

variable-name — a variable name; not evaluated.

object-form — a form; evaluated to produce object.

object — an object.

declaration — a declare expression; not evaluated.

forms — an implicit progn.

results — the values returned by the forms.

Description:

WITH-PROPERTIES establishes a lexical environment for referring to the properties in object named by the given property-names as though they were lexically bound variables.

Within this context the value of each property can be specified by using its name, or the corresponding variable-name, if one was passed for that property. Both setf and setq can be used to set the value of the property.

WITH-PROPERTIES translates an appearance of property-name or variable-name as a variable into a call to PROPERTY-VALUE.

Examples: None

Exceptional Situations:

The consequences are undefined if any property is not present in object.

Notes:

A WITH-PROPERTIES expression of the form:

     (with-properties (property-entry1 ... property-entryn) instance-form form1 ... formk)

expands into the equivalent of

     (let ((in instance-form))
       (symbol-macrolet (Q1 ... Qn) form1 ... formk))

where Qi is

     (property-entryi () (property-value in 'property-entry))

if property-entryi is a symbol, and is

     (variable-namei () (property-value in 'property-namei))

if property-entryi is of the form

     (variable-namei 'property-namei)

Also, note that the standard macro WITH-ACCESSORS works on objects too.