'Hope it won't bother my using defmacro
s named in the style of keywords (colon-prefixed, e.g., :set-this
or :get-that
): it apparently tricks ELisp
from otherwise requiring quote
d symbols ('
) or function symbols (#'
).
For example:
(foo :set-this value-that) ; line 0
Nevermind that: the problem goes as follows.
Say there are two "keywordp
"-like defmacro
s with one parameter, and given a cl-flet*
context, there should be two similar forms (as in line #0
), but with two different macros and arguments.
An MWE is the following.
(defmacro :m (x) `(length ,x)) ; line 1
⇒ :m
(and (keywordp :m) (macrop :m)) ; line 2
⇒ t
(:m `(3)) ; line 3
⇒ 1
(defmacro :w (x) `(length (nreverse ,x))) ; line 4
⇒ :w
(and (keywordp :w) (macrop :w)) ; line 5
⇒ t
(:w `(6)) ; line 6
⇒ 1
(defun x (y z) (eval `(,y ,z))) ; line 7
⇒ x
(x :m `(8)) ; line 8
⇒ Invalid function: 8
(x :w '(9)) ; line 9
⇒ Invalid function: 8
(- (eval `(:m '(8)) (eval `(:w `(9))) ; line 10
⇒ 0
The faulty code is in line #7
.
In these simple cases, it don't matter if the argument-list is backquoted `(8)
, quoted '(9)
, or returned as (list 8)
.
Lines #8
and #9
show what is wrong.
Yet, line #10
shows that eval
uating as it "should be" is possible.
Now, if instead of defun
there were a defmacro
:
(defmacro x (y z) `(eval (,y ,z))) ; line 11
⇒ x
then lines #8
or #9
would be equivalent to line 10
, but this is impossible within a cl-flet*
.
Any hints? Thank s.