[CM] what would be like Python dictionaries?

Bob Coyne bobcoyne@worldnet.att.net
Tue, 06 Apr 2004 12:28:26 -0400


Get, getf, and gethash take a third default value for exactly this
purpose.  The default value is returned (rather than nil) when no
such property is present.  For example:.

;; Starting off, there's no property.  It returns the default. 
(get :house :size :no-value) => :no-value

;; Now add the property with a value of nil. 
(setf (get :house :size) nil)

;; It now finds the (null) value of the property rather than returning 
default.
(get :house :size :no-value) => nil


Rick Taube wrote:

> property lists, association lists or hash tables are all reasonable 
> choices for implementing dictionaries. if you have just a few 
> definitions then plists are probably the easiest way to go. plists can 
> be associated with particular symbols using 'get' and '(setf get)' or 
> you can treat any list as a plist if you use 'getf'. however, testing 
> for the existence of a property in a property list is a bit tricky 
> because both 'get' and 'getf' return false in the case of a nil 
> property value OR in the case where the property itself is undefined 
> in the plist. but you can use 'member' to see if a property name 
> appears in the list or not.
>
>> _______________________________________________
>> Cmdist mailing list
>> Cmdist@ccrma.stanford.edu
>> http://ccrma-mail.stanford.edu/mailman/listinfo/cmdist
>
>
> _______________________________________________
> Cmdist mailing list
> Cmdist@ccrma.stanford.edu
> http://ccrma-mail.stanford.edu/mailman/listinfo/cmdist
>