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

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

Re: How to tame compiler?


From: Stefan Monnier
Subject: Re: How to tame compiler?
Date: Fri, 30 Apr 2021 18:20:26 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Emanuel Berg via Users list for the GNU Emacs text editor [2021-05-01 00:06:30] 
wrote:
> Jorge P. de Morais Neto wrote:
>>>> Is there a way to avoid these warnings?
>>> Yes: don't abuse `eval` ;-)
> Stefan Monnier who wrote that last part, or anyone else for
> that matter, what is the rule of thumb when to and when not to
> use `eval'?

Use it only when you have to, otherwise don't use it.

>   (let ((cmd (cl-find-if (lambda (c)
>                            (and (eq (car c) #'wrap-search)
>                                 (not (string= (cl-caddr c) "")) ))
>                          command-history) ))
>     (if cmd
>         (if (= new-options 1)
>             (eval cmd)

Here, as in your other example, you have to use `eval`, because
`command-history` was defined to contain a list of ELisp expressions and
those can't be used other than via `eval`.

So I'll grant you a pass for this time.

If you were in a position to control the format of history variable,
then you wouldn't have to use `eval` here, OTOH: you could define that
variable to hold a list of *functions* and you'd just use `funcall`
instead of `eval`.


        Stefan




reply via email to

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