On 8/27/10 12:55 PM, Alexander Burger wrote:
Hi Jon,
Each property in a symbol's tail is either a symbol (like the single
KEY above, then it represents a boolean value), ...
Can such a "single KEY" represent anything else than the boolean 'T'?
If it cannot, I think the docs should say so. If it can, I'd like to
see an example!
Yes, it can be any symbol.
If you create a "normal" propery (not a single KEY but a KEY/VAL pair),
you call it like
(put 'A 'drink 'vodka)
and you get a symbol tail of
|
V
+-----+-----+ +-----+-----+
| | | ---+---> | 'A' | / |
+--+--+-----+ +-----+-----+
|
V
+-------+-------+
| vodka | drink |
+-------+-------+
However, if the property _value_ is 'T' (i.e. you specify a boolean
property),
(put 'A 'thirsty T)
then it the value is omitted as an optimization to save space, and only
the key is stored:
|
V
+---------+-----+ +-----+-----+ +-----+-----+
| thirsty | ---+---> | | | ---+---> | 'A' | / |
+---------+-----+ +--+--+-----+ +-----+-----+
|
V
+-------+-------+
| vodka | drink |
+-------+-------+
In that way, boolean properties need only a single cell, instead of two!
You can see the result with 'getl'
: (getl 'A)
-> (thirsty (vodka . drink))
and the 'get' family of functions knows about that speciality and
returns 'T':
: (get 'A 'thirsty)
-> T
: (get 'A 'drink)
-> vodka
Cheers,
- Alex
Hi Alex,
Yes, but what I meant was that a "single KEY" cannot or will not
represent a boolean NIL (unless you show me), and therefor I think the
docs should say so, like this:
Each property in a symbol's tail is either a symbol (like the single KEY
above, then it represents a boolean value T), ...
/Jon
--
UNSUBSCRIBE: mailto:[email protected]?subject=unsubscribe