在下面的代码中应该避免 eval 吗?如果是这样,怎么做?或者这是使用 eval 更好的特殊情况之一?
(dolist (command '(....))
(eval
`(defadvice ,command (around blah activate)
...)))
对于上述成语的真实示例:
(dolist (command '(paredit-comment-dwim comment-dwim))
(eval
`(defadvice ,command (around my-check-parens-and-warn-for-comment activate)
(if (and (called-interactively-p 'any)
(use-region-p))
(progn
(my-check-parens-and-warn-if-mismatch "You commented out a region and introduced a mismatched paren")
ad-do-it
(my-check-parens-and-warn-if-mismatch "You uncommented out a region and introduced a mismatched paren"))
ad-do-it))))