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

[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 <address@hidden>,
 "Drew Adams" <address@hidden> 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, address@hidden
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 ***


reply via email to

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