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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: never use `eval' (was: Re: How to mapcar or across a list?)


From: Barry Margolin
Subject: Re: never use `eval' (was: Re: How to mapcar or across a list?)
Date: Wed, 15 Jul 2015 20:01:55 -0400
User-agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X)

In article <mailman.6982.1437001117.904.help-gnu-emacs@gnu.org>,
 Emanuel Berg <embe8573@student.uu.se> wrote:

> "Pascal J. Bourguignon" <pjb@informatimago.com>
> writes:
> 
> > It's always a bad idea to use eval, because eval
> > evalutes in the nil environment, not in the local
> > lexical envrionment.
> 
> I have used `eval' eight times in my current setup of
> 75 files.
> 
> Tho some of this code I wrote several years ago, I'd
> be happy to correct it. Any hints - general or
> specific - are appreciated.
> 
> ;; From: http://user.it.uu.se/~embe8573/conf/emacs-init/faces.el
> 
> (defun set-color-face (name front &optional bold back)
>   (eval `(defvar ,(make-symbol name)))
>   (eval `(setq ,(intern name)
>                `((t (:foreground ,front
>                      :background ,back
>                      :bold       ,bold) )))))

(eval `(setq ,<expr> <val>))

can practically always be replaced with:

(setf (symbol-value <expr>) <val>)

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


reply via email to

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