[Date Prev][Date Next][Thread Prev][][Date Index][Thread Index]

Re: bogus change(s) in cl-macs.el



> I found the simplest way to explain the bug:

> (macroexpand
>  '(labels ((FOO nil FOO-BODY)
> 	   (BAR nil BAR-BODY))
>     (FOO)
>     (BAR)))

> (let ((--cl---cl-var---- nil)
>       (--cl---cl-var---- nil))
>   (progn
>     (progn
>       (set '--cl---cl-var---- #'(lambda nil BAR-BODY))
>       (set '--cl---cl-var---- #'(lambda nil FOO-BODY)))
>     (funcall (symbol-value '--cl---cl-var----))
>     (funcall (symbol-value '--cl---cl-var----))))

> One of two functions FOO and BAR is disregarded as you see.

Well, actually we can't see it here because you haven't used print-gensym
to distinguish symbols with the same name.  But indeed:

  (labels ((foo nil 1) (bar nil 2)) (cons (foo) (bar)))

returns (1 . 1).  This is because cl's macro environment uses symbol names
rather than symbols for symbol-macros, so if two symbols have the same name
(i.e. `eq', not just `equal') and they both are symbol-macros, then
CL screws up.  I'm working on a patch for that.


        Stefan


PS: A symbol-macro is a macro `foo' that is not triggered by (foo bla bla)
but by a mere `foo'.
E.g. (symbol-macrolet ((x (hello))) (+ x 1)) => (+ (hello 1))