[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Concern around use of eval
From: |
Joost Kremers |
Subject: |
Re: Concern around use of eval |
Date: |
19 Mar 2015 08:12:04 GMT |
User-agent: |
slrn/pre1.0.0-18 (Linux) |
Tassilo Horn wrote:
> Well, in case the `lh/label' value is available at compile-time then
> `lh/define-predicates' can also be a macro and you can go like this:
>
> --8<---------------cut here---------------start------------->8---
> (defvar lh/labels '("label1" "label2" "label3"))
>
> (defmacro lh/gen-predicate (label)
> `(defun ,(intern (concat "lh/" label "-p")) ()
> (member ,label *lh/system-label-store*)))
>
> (defmacro lh/define-predicates ()
> `(progn
> ,@(mapcar (lambda (label)
> `(lh/gen-predicate ,label))
> lh/labels)))
>
> (lh/define-predicates)
> --8<---------------cut here---------------end--------------->8---
Why not do it at the top level directly? E.g.:
,----
| (defvar lh/labels '("label1" "label2" "label3"))
|
| (defmacro lh/gen-predicate (label)
| `(defun ,(intern (concat "lh/" label "-p")) ()
| (member ,label *lh/system-label-store*)))
|
| (mapc (lambda (label)
| (lh/gen-predicate label))
| lh/labels)
`----
--
Joost Kremers joostkremers@fastmail.fm
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)
- Concern around use of eval, Les Harris, 2015/03/19
- Re: Concern around use of eval, Stefan Monnier, 2015/03/19
- 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