Next: Object Plists, Up: Symbol Properties [Contents][Index]
Association lists (see Association Lists) are very similar to property lists. In contrast to association lists, the order of the pairs in the property list is not significant since the property names must be distinct.
Property lists are better than association lists for attaching
information to various Lisp function names or variables. If all the
associations are recorded in one association list, the program will need
to search that entire list each time a function or variable is to be
operated on. By contrast, if the information is recorded in the
property lists of the function names or variables themselves, each
search will scan only the length of one property list, which is usually
short. This is why the documentation for a variable is recorded in a
property named variable-documentation
. The byte compiler
likewise uses properties to record those functions needing special
treatment.
However, association lists have their own advantages. Depending on your application, it may be faster to add an association to the front of an association list than to update a property. All properties for a symbol are stored in the same property list, so there is a possibility of a conflict between different uses of a property name. (For this reason, it is a good idea to choose property names that are probably unique, such as by including the name of the library in the property name.) An association list may be used like a stack where associations are pushed on the front of the list and later discarded; this is not possible with a property list.
Next: Object Plists, Up: Symbol Properties [Contents][Index]