[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: let-alist can't deal with the keys which includes spaces.
From: |
Emanuel Berg |
Subject: |
Re: let-alist can't deal with the keys which includes spaces. |
Date: |
Tue, 20 Jul 2021 19:50:37 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
tomas wrote:
>> Uhm, what is the purpose with `let-alist' and "dotted
>> symbols" to begin with?
>
> `let-alist' is just a handy way to destructure an alist.
>
> Assume we have
>
> (setq colours '((poppy . red) (cornflower . blue) (sunflower . yellow)))
>
> Instead of doing
>
> (let ((rose (alist-get 'rose colours))
> (cornflower (alist-get 'cornflower colours))
> (sunflower (alist-get 'sunflower colours)))
> ;; do something with rose, cornflower...
> )
>
> you just do
>
> (let-alist colours
> ;; do something with .rose, .cornflower...
> )
The docstring is confusing IMO, your example so-so but better
because of the initial "`let-alist' is just a handy way to
destructure an alist" line, but why not just put it like this?
(setq numbers '((one . 1)
(two . 2)
(three . 3)
(four . 4) ))
(let-alist numbers
(list .one .two .three .four) ) ; (1 2 3 4)
> The dots are part of the symbol name, they aren't special
> Lisp syntax.
Perhaps, but in practice they are part of the `let-alist'
special syntax.
--
underground experts united
https://dataswamp.org/~incal
- let-alist can't deal with the keys which includes spaces., Hongyi Zhao, 2021/07/20
- Re: let-alist can't deal with the keys which includes spaces., tomas, 2021/07/20
- Re: let-alist can't deal with the keys which includes spaces., Omar Polo, 2021/07/20
- Re: let-alist can't deal with the keys which includes spaces., tomas, 2021/07/20
- Re: let-alist can't deal with the keys which includes spaces., Emanuel Berg, 2021/07/20
- Re: let-alist can't deal with the keys which includes spaces., tomas, 2021/07/20
- Re: let-alist can't deal with the keys which includes spaces.,
Emanuel Berg <=
- Re: let-alist can't deal with the keys which includes spaces., Emanuel Berg, 2021/07/20
- Re: let-alist can't deal with the keys which includes spaces., tomas, 2021/07/21
- Re: let-alist can't deal with the keys which includes spaces., Emanuel Berg, 2021/07/21