Alexander Burger <a...@software-lab.de> writes:

Hi Alex,

>> > 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
>> ...
>> 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)?
>
> Right, in this sense it is not a property list. But if we obtained it
> with 'getl', we know that it is a *copy* of a symbol's internal property
> list.
>
>> An association list because it is build of
>> dotted pairs? Or just a list?
>
> 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?
>
> No. An association list exists only in the head of a programmer. It
> becomes manifested in the moment a programmer applies 'assoc' or 'asoq'
> to it.
>
> *Any* list can be an association list. Calling 'assoc' on a list makes
> only sense, though, if it consists (at least partially) of cells where
> the CARs should be searched for.
>
> The above list ((VAL . KEY) KEY (VAL . KEY)) can be taken as an
> association list if you want to search for the VAL elements.
>
>
>> Are these all alists?
>> 
>> #+begin_src picolisp
>> ((VAL . KEY) KEY (VAL . KEY))
>> 
>> (VAL KEY KEY VAL  KEY)
>> 
>> ((VAL . KEY) KEY VAL KEY))
>
> Yes. 'assoc' ignores atomic list elements. So 'assoc' on the the second
> list will always return NIL, no matter what the search key is.

I'm getting closer to understand it. 

So these are all 'alists' where applying 'assoc' or 'asoq' would make
sense:

#+begin_src picolisp
((VAL . KEY) KEY (VAL . KEY))
 
((KEY VAL VAL) (KEY VAL VAL) KEY VAL)

((VAL . KEY) KEY VAL KEY))

#+end_src picolisp

it does not matter that the cells in the second one are not dotted
pairs. 

On the other hand, this

#+begin_src picolisp
(KEY VAL KEY VAL KEY VAL KEY VAL)
#+end_src picolisp

is an 'association list' in the broader sense, because by convention
(and in the programmers head) the elements are key/val pairs, but
however 'assoc' or 'asoq' would not work. 

And property list extracted with 'lget' from a symbol would be 'true'
alists too if the programmer would simply redefine the VALS as KEYs and
vice verse in his head before applying 'assoc' or 'asoq'.  

Or if he actually swaps keys and vals, since (Emacs Lisp) functions like
'rassoc' and 'rasoq' do not exist in PicoLIsp. 

One last question:

#+begin_src picolisp
((VAL . KEY) KEY (VAL . KEY))

((VAL KEY) KEY (VAL KEY))

((VAL VAL KEY) (VAL VAL KEY) (VAL . KEY))
#+end_src picolisp

would each of the above be a valid property list if assigned with 'lput'
to a symbol?

-- 
cheers,
Thorsten

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

Reply via email to