Alexander Burger <[email protected]> writes:
Hi Alex,
> 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":
>
> Symbol
> |
> V
> +-----+-----+ +-----+-----+
> | | | 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))
thanks for the explanations!
But what is the returned list ((VAL . KEY) KEY (VAL . KEY)) then?
A property-list (not really, because its not part of the symbols
internal cell structure)? An association list because it is build of
dotted pairs? Or just a list? Whats the difference to an association
list, except of course that every alist is a list? When is a list not an
alist in PicoLisp? Is a property list an alist because its elements are
(reversed) dotted pairs?
>> 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?
I think thats the point where I'm confused a bit. I meant dotted pairs
but wrote cons cells - but isn't that the same?
Are these all alists?
#+begin_src picolisp
((VAL . KEY) KEY (VAL . KEY))
(VAL KEY KEY VAL KEY)
((VAL . KEY) KEY VAL KEY))
#+end_src
--
cheers,
Thorsten
--
UNSUBSCRIBE: mailto:[email protected]?subject=Unsubscribe