Hi Thorsten,

> as far as I understand, property lists in PicoLisp are kind of reversed:
> ,----------------------------------------------
> | ((val1 . key1)(val2 . key2) ...(valN . keyN))
> `----------------------------------------------

Correct. The value of a property is in the CAR of the corresponding
cell, to allow it to be treated as a 'var' and thus be passed to
place-modifying functions ('push', 'set', 'inc' etc.).

This can be done with the 'prop' and '::' functions. For example, to
exchange two properties 'x' and 'y' of a symbol 'A':

   (with 'A (xchg (:: x) (:: y)))

> Are plists only used as property lists of symbols, or can they exist

Property-"list"s are an *internal* representation of value-key-pairs in
symbols. They don't actually exist in a physically accessible form.

See e.g. the "Symbol" description in "doc64/structures":

      +-----+-----+                                +-----+-----+
      |  |  | VAL |                                |'cba'|'fed'|
      +--+--+-----+                                +-----+-----+
         | tail                                       ^
         |                                            |
         V                                            | name
         +-----+-----+     +-----+-----+     +-----+--+--+
         |  |  |  ---+---> | KEY |  ---+---> |  |  |  |  |
         +--+--+-----+     +-----+-----+     +--+--+-----+
            |                                   |
            V                                   V
            +-----+-----+                       +-----+-----+
            | VAL | KEY |                       | VAL | KEY |
            +-----+-----+                       +-----+-----+

The property-cells are part of the symbol's internal structure.

We can see from the above that while a symbol's TAIL cell may point to a
property list, this is not a normal NIL-terminated list, because it may
be followed by the symbol's name.

You can genearate a list of value-key-pairs from a symbol's properties
with 'getl', but this will always return a freshly cons'ed list, not
identical to the symbol's internal cell structure. In the above example,
the returned list would be something like ((VAL . KEY) KEY (VAL . KEY))

> Are plists always built with cons cells and alists only sometimes?

Sure. Everything in PicoLisp is built with cells. Why should association
lists be only sometimes so?

♪♫ Alex
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to