[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Concern around use of eval
From: |
Stefan Monnier |
Subject: |
Re: Concern around use of eval |
Date: |
Thu, 19 Mar 2015 10:07:55 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
> | (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)
; -*- lexical-binding:t -*-
(defvar lh/labels '("label1" "label2" "label3"))
(defun lh/gen-predicate (label)
(defalias (intern (concat "lh/" label "-p"))
(lambda () (member label *lh/system-label-store*))))
(defun lh/define-predicates ()
(mapc #'lh/gen-predicate lh/labels))
(lh/define-predicates)
> Stylistically, is there a better way to do this or am I just being
> weird about (eval) and should just get over it?
You're not weird about `eval'. It's kind of like self-modifying code:
there are cases where you *really* need it, but they're extremely rare
and every time you use it when it's not *really* indispensable,
kittens die.
Stefan
- Concern around use of eval, Les Harris, 2015/03/19
- Re: Concern around use of eval,
Stefan Monnier <=
- Re: Concern around use of eval, Thierry Volpiatto, 2015/03/20
- Message not available
- Re: Bug in Elisp font-locking, Tassilo Horn, 2015/03/20
- Re: Bug in Elisp font-locking, Stefan Monnier, 2015/03/20
- Re: Bug in Elisp font-locking, Tassilo Horn, 2015/03/20
- Re: Bug in Elisp font-locking, Stefan Monnier, 2015/03/20