Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Is SBCL retarded?

Name: Anonymous 2013-02-09 13:25

or am i just doing something wrong?


(defmacro test (&body c)
  `(progn ,(test2 c)))

(defmacro test2 (&body c)
  (format t "~A~%" c)
  `(progn (car ,c) ,@c))


test2 compiles just fine
upon trying to compile test i get:

; in: DEFMACRO TEST
;     COMMON-LISP::C
;
; caught STYLE-WARNING:
;   undefined function: C
;
; compilation unit finished
;   Undefined function:
;     C
;   caught 1 STYLE-WARNING condition



How the fuck does it see C as a function when it's clearly in the argument position for test2?

Name: Anonymous 2013-02-09 13:57

think about what a macro does.

- It takes input
- It turns that input into S-expressions
- Returns the output
- Compiler then evals the output

test is basically doing:

(eval (progn (eval (progn (car c) ,@c))))
=>(eval (progn ,@c))
=>,@c


and in the manner you're calling test2,
c = ( (exps...) )

thus the final result would be interpreting the first expression in c as a function.



tl;dr: test2 should be a defun, not defmacro

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List