[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: alists with precomputed variables
From: |
Barry Margolin |
Subject: |
Re: alists with precomputed variables |
Date: |
Wed, 21 Jan 2009 00:49:23 -0500 |
User-agent: |
MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) |
In article <mailman.5420.1232514814.26697.help-gnu-emacs@gnu.org>,
"Drew Adams" <drew.adams@oracle.com> wrote:
> > (setq my-var 20)
> > (setq my-alist '((p1 . 10) (p2 . my-var)))
> >
> > I naively thought that would give me
> > ((p1 . 10) (p2 . 20))
> >
> > but it instead results in
> > ((p1 . 10) (p2 . my-var))
> >
> > How can I get what I expected?
>
> (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)))
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***