all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Concern around use of eval
@ 2015-03-19  6:53 Les Harris
  2015-03-19  8:00 ` Tassilo Horn
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Les Harris @ 2015-03-19  6:53 UTC (permalink / raw
  To: help-gnu-emacs

I have a situation where I want to generate a bunch of nearly identical
predicate functions. Previously I had just manually defined these things
one by one but was never happy with such an obvious inefficiency (or
maintaining it). Tonight I decided I'd fix this and whacked them and
implemented a way of doing it where I can iterate over a list containing
labels and define these predicate functions using those labels:

,----
| (defvar lh/labels '("label1" "label2" "label3"))
| 
| (defmacro lh/gen-predicate (label)
|   `(defun ,(intern (concat "lh/" label "-p")) ()
|             (member ,label *lh/system-label-store*)))
| 
| (defun lh/define-predicates ()
|   (dolist (label lh/labels)
|     (eval `(lh/gen-predicate ,label))))
| (lh/define-predicates)
`----

Now this all works fine and I get my auto-generated predicates, so
success. My question/concern/niggle is around the use of (eval) in
lh/define-predicates. If I don't put eval in there then the defun the
macro evaluates into never gets evaluated itself. Stylistically, is
there a better way to do this or am I just being weird about (eval) and
should just get over it?

-- 
Do they only stand
By ignorance, is that their happy state,
The proof of their obedience and their faith?




^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2015-03-21  7:55 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-19  6:53 Concern around use of eval Les Harris
2015-03-19  8:00 ` Tassilo Horn
     [not found] ` <mailman.2302.1426752018.31049.help-gnu-emacs@gnu.org>
2015-03-19  8:12   ` Joost Kremers
2015-03-19  8:31     ` Tassilo Horn
     [not found]     ` <mailman.2305.1426753885.31049.help-gnu-emacs@gnu.org>
2015-03-20 19:54       ` Joost Kremers
2015-03-19 14:07 ` Stefan Monnier
2015-03-20 15:17   ` Thierry Volpiatto
2015-03-20 17:19     ` Bug in Elisp font-locking (was: Concern around use of eval) Tassilo Horn
2015-03-20 17:31       ` Bug in Elisp font-locking Stefan Monnier
2015-03-20 17:43         ` Drew Adams
2015-03-20 18:47         ` Tassilo Horn
2015-03-20 20:38           ` Stefan Monnier
2015-03-20 22:45             ` Tassilo Horn
2015-03-21  0:06               ` Johan Bockgård
2015-03-21  7:26                 ` Tassilo Horn
2015-03-21  2:33               ` Stefan Monnier
2015-03-21  7:55                 ` Tassilo Horn

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.