This is my code and the warning. If anybody knows how I can get rid of the warnings, I will be thankful as my code is giving the right output.
Asked
Active
Viewed 774 times
-3
-
http://stackoverflow.com/questions/267862/what-makes-lisp-macros-so-special – Rainer Joswig Mar 04 '16 at 17:42
-
2Please post actual code, not an image of code. – Joshua Taylor Mar 04 '16 at 17:54
-
1I think you're misunderstanding what the argument list to **defmacro** does. Doing `(defmacro lcomp (exp for var in list) ...)` means that you can call `(lcomp a b c d e)`. I don't think that's what you're expecting, is it? – Joshua Taylor Mar 04 '16 at 17:56
-
@JoshuaTaylor right now the answer that I get is (4 64 36) which is needed but I am not sure what you exactly mean by(lcomp a b c d e) – Tim Jones Mar 04 '16 at 18:08
-
1I mean that all the things in the lama list of your macro are variables. However, I don't think you mean for "for" and "in" to be variables. The defmacro lambda lay doesn't do pattern matching that way – Joshua Taylor Mar 04 '16 at 18:10
-
@JoshuaTaylor: It's not 'his' macro. The oldest version I found is here http://stackoverflow.com/a/4621882/69545 – Rainer Joswig Mar 04 '16 at 18:29
-
well I just realised that that the warning is on Linux only, on Windows the code is fine :/ – Tim Jones Mar 04 '16 at 18:36
-
1@Tim no, the code has the same issues in both places, even if one compiler doesn't complain as loudly. – Joshua Taylor Mar 04 '16 at 18:50
-
@Joshua so how do you think I can solve it? or is there a way to solve it? – Tim Jones Mar 04 '16 at 18:56
-
1I'm voting to close this question as off-topic because it's based on code that OP didn't write and hasn't attributed, and can't be useful to others (all code and warnings are images, so there is no searchability). – Joshua Taylor Mar 05 '16 at 02:16
-
@TimJones Until the question has actual text (not an **image** of the code), people won't be able to search for it, so it's not useful to them. The downvote button tooltip includes "it is unclear or not useful", so I think it applies. As to "solving" this, if you understand why `(defun foo (a b) (+ 1 a))` would generate a warning about b being unused, then you already understand why you get the warnings you do with this macro. Your declaration says that the macro takes seven arguments, and you're only using five of them. – Joshua Taylor Mar 07 '16 at 21:18
-
1@TimJones On top of that, you're asking a question about code that you didn't write. That's fine, **if** you provide attribution for it. Rainer Joswig found one of the places that code has appeared before, but you haven't said where you've found it, so you're essentially passing it off as your own (you even said "This is my code"). – Joshua Taylor Mar 07 '16 at 21:20
1 Answers
2
Their are two ways:
- you actually use the variables
FOR
andIN
- you declare to ignore the variables
FOR
andIN
Example:
CL-USER 30 > (defmacro foo (bar)
`(list))
FOO
CL-USER 31 > (compile 'foo)
;;;*** Warning in FOO: BAR is bound but not referenced
FOO
((FOO #<CONDITIONS::SIMPLE-STYLE-WARNING 402000E4DB>))
NIL
CL-USER 32 > (defmacro foo (bar)
(declare (ignore bar))
`(list))
FOO
CL-USER 33 > (compile 'foo)
FOO
NIL
NIL

Rainer Joswig
- 136,269
- 10
- 221
- 346
-
I understand that but what should I add to my code in order to get the warnings away? – Tim Jones Mar 04 '16 at 17:33
-
-
-
well to be honest I would like to know something which will near my code not a new code – Tim Jones Mar 04 '16 at 17:40
-
@TimJones The solution Rainer mentioned lets you keep all your code. All you'd have to add is `(declare (ignore for in))`, and everything else would be the same. That's about as "near [your] code" as it can be. – Joshua Taylor Mar 07 '16 at 21:21