help-gnu-emacs
[Top][All Lists]
Advanced

[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: tomas
Subject: Re: let-alist can't deal with the keys which includes spaces.
Date: Tue, 20 Jul 2021 18:20:13 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

On Tue, Jul 20, 2021 at 05:35:22PM +0200, Omar Polo wrote:
> 
> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
> 
> > I adapted the examples given on
> > <https://www.gnu.org/software/emacs/manual/html_node/elisp/Association-Lists.html>
> > to the following:
> >
> > ;;;
> > (setq colors '(("rose merry" . red) (lily (belladonna . yellow))))
> >
> > (let-alist colors
> >   (if (eq ."rose merry" 'red)
> >       .lily.belladonna))
> > ;;;

[...]

> Strings and symbols are different data types and such have different
> properties and different syntax.

yes, and `let-alist' expects symbols as keys.

> Moreover, I don't know how wise is to use strings as alist keys (symbols
> are interned, strings doesn't necessary).  I suggest using something
> like

In the general case, you can use strings (and other Lisp objects) as keys
in an alist. You have to use the right functions (i.e. `assoc' for the
strings, which by default uses `equal' as equality predicate).

But not for `let-alist'.

Cheers
 - t

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]