[Top][All Lists]

[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: Hongyi Zhao
Subject: Re: let-alist can't deal with the keys which includes spaces.
Date: Tue, 20 Jul 2021 21:21:32 +0800

On Tue, Jul 20, 2021 at 8:49 PM <> wrote:
> On Tue, Jul 20, 2021 at 07:12:14PM +0800, Hongyi Zhao wrote:
> > I adapted the examples given on
> > <>
> > to the following:
> >
> > ;;;
> > (setq colors '(("rose merry" . red) (lily (belladonna . yellow))))
> >
> > (let-alist colors
> >   (if (eq ."rose merry" 'red)
> >       .lily.belladonna))
> > ;;;
> >
> > When I try to evaluate the above code snippet, the following error is 
> > triggered:
> It's not the space. It's the dot ".". This is wrong Lisp syntax:
>   (eq ."rose merry" 'red)
> Also the dots in .lily.belladonna look strange. This will be the next
> syntax error.
> BTW., if you take the dot out, like so
>   (eq "rose merry" 'red)

The dot syntax is described on
as follows:

Macro: let-alist alist body

Creates a binding for each symbol used as keys the association list
alist, prefixed with dot. This can be useful when accessing several
items in the same association list

> the syntax will be correct, but the expression itself won't make much
> sense, because it will always be false. The string "rose merry" can't
> ever be `eq' to the symbol 'red.
> What are you trying to achieve?

I don't want to compare the string "rose merry" and red, instead, the
purpose is to extract the value whose key is "rose merry", and then
compare the result with 'red, just as the example given on
does, i.e., I want to mimic the following one:

(setq colors '((rose . red) (lily (belladonna . yellow) (brindisi . pink))))
(let-alist colors
  (if (eq .rose 'red)
=> yellow

But in my case, I changed the key 'rose to "rose merry" which
triggered the error discussed here.

  - HY

reply via email to

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