[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: Omar Polo
Subject: Re: let-alist can't deal with the keys which includes spaces.
Date: Tue, 20 Jul 2021 17:35:22 +0200
User-agent: mu4e 1.4.15; emacs 28.0.50

Hongyi Zhao <> writes:

> 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))
> ;;;

It's not an error, it's totally expected.  When you type


emacs lisp (and I guess every lisp out there) sees the symbol

Now, when you type

        ."rose merry"

it just doesn't make sense (from the emacs lisp parser POV).  there's a
lonely dot and a string.  A lonely dot is not a valid symbol.  In
addition, remember that spaces aren't strictly necessary.  Consider for

        (let ((.a 5))
        ;; => "hello"

        ;; equivalent to
        (let ((.a 5))

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

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

        (setq colors '((rose-merry . red) (lily (belladonna . yellow))))

and following the kebab-case style.


> When I try to evaluate the above code snippet, the following error is 
> triggered:
> Debugger entered--Lisp error: (invalid-read-syntax ". in wrong context" 8 28)
>   read(#<buffer *scratch*>)
>   elisp--preceding-sexp()
>   elisp--eval-last-sexp(t)
>   eval-last-sexp(t)
>   eval-print-last-sexp(nil)
>   funcall-interactively(eval-print-last-sexp nil)
>   call-interactively(eval-print-last-sexp nil nil)
>   command-execute(eval-print-last-sexp)
> It seems that let-alist can't deal with the keys which includes
> spaces. Any hints for this problem will be highly appreciated.
> Regards

reply via email to

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