4

I've stared at Steele's Common Lisp the Language until I'm blue in the face, and still have this question. If I compile:

(defun x ()
  (labels ((y ()))
    5))
(princ (x))
(terpri)

this happens:

home:~/clisp/experiments$ clisp -c -q x.lisp
;; Compiling file /u/home/clisp/experiments/x.lisp ...
WARNING in lines 1..3 :
function X-Y is not used.
Misspelled or missing IGNORE declaration?
;; Wrote file /u/home/clisp/experiments/x.fas
0 errors, 1 warning
home:~/clisp/experiments$ 

Fair enough. So how do I ask the compiler to ignore function y? I tried this:

(defun x ()
  (labels (#+ignore(y ()))
    5))
(princ (x))
(terpri)

and it worked:

home:~/clisp/experiments$ clisp -c -q y.lisp
;; Compiling file /u/home/clisp/experiments/y.lisp ...
;; Wrote file /u/home/clisp/experiments/y.fas
0 errors, 0 warnings
home:~/clisp/experiments$ 

but somehow I don't think that's what the warning is suggesting that I do.

What do I do?

Bill Evans at Mariposa
  • 3,590
  • 1
  • 18
  • 22
  • 1
    Just for reference, `#+ignore` lets the reader skip the entire next form (unless a there is `ignore` in `*features*`, of course). – Svante Feb 26 '12 at 22:47
  • Ed Zachary. That was my evil plan. But the good plan outlined in the answer below prevailed. :) – Bill Evans at Mariposa Feb 27 '12 at 00:43
  • CLtl and CLtl2 are both outdated books, and would recommend them only to people interested in the history of lisp, rather than be used as references or learning material. For modern ANSI common lisp reading I would recommend both Practical Common Lisp by Peter Seibel and Land of Lisp by Conrad Barski. – Pavel Penev Mar 02 '12 at 13:38

1 Answers1

9

GNU CLISP is asking you to declare the function to be ignored.

(defun x ()
  (labels ((y ()))
    (declare (ignore (function y)))
    5))

Alternatively (especially if this is the result of a macro expansion where it depends on the user whether y is actually used or not),

(defun x ()
  (labels ((y ()))
    (declare (ignorable (function y)))
    5))

(Wherever you are expected to write (function y), you are free to use the reader abbreviation #'y instead.)

Matthias Benkard
  • 15,497
  • 4
  • 39
  • 47