[ < ] | [ > ] | [ << ] | [Plus haut] | [ >> ] | [Top] | [Table des matières] | [Index] | [ ? ] |
Association lists (voir la section 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 your program keeps all of
its associations in one association list, it will typically need to search
that entire list each time it checks for an association. This could be
slow. By contrast, if you keep the same information 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 beginning the property name with the program's usual name-prefix for variables and functions.) 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.
Ce document a été généré par Eric Reinbold le 13 Octobre 2007 en utilisant texi2html 1.78.