[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: alists with precomputed variables
From: |
Drew Adams |
Subject: |
RE: alists with precomputed variables |
Date: |
Tue, 20 Jan 2009 23:54:14 -0800 |
> > (setq my-alist `((p1 . 10) (p2 ,@my-var)))
>
> I guess that might work, but ,@ is supposed to be followed by an
> expression that returns a list, so that it can be spliced into the
> containing list. It would be better to write:
>
> (setq my-alist `((p1 . 10) (p2 . ,my-var)))
I don't know about "supposed to be" (not only lists are spliced into list
structure), but yes, `.' followed by `,' might be clearer for an atom. But if I
didn't know the value of `my-var', I would probably use `,@', personally.
Anyway, the important thing is to read up on lists in the doc.
There are several ways to get something like what was requested.
The variants I gave are not all equivalent, in any case. In particular, '(p1 .
10) is typically not the same as (cons 'p1 10), in many contexts.