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
-- 
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe

Reply via email to