From: Josef Eschgfaeller
Subject: Re: defvar
Date: 
Message-ID: <379E6F97.4BF94FBA@felix.unife.it>
Kent Pitman wrote (modified):

> (declaim '(inline ignore-please))
> (defun ignore-please (&rest x) ; (*)
>   (declare (ignore x)) nil)

Thank you. It works well, but I cannot understand why (ignore x)
works, because x in this place should become a list, but it seems
that normally I cannot write (declare (ignore '(x y))) or
(declare (ignore (list x y))).

  (defun f (&rest x) (declare (ignore x)) 7)

too is accepted by the compiler. But why?

  (defun f (&rest x) (+ x x))

is obviously not allowed. What is the difference?
It seems that, if I want to use it for only one
variable, both x alone and &rest x in (*) are correct.

Do I make a mistake, or is it a rule that one can use
such short forms in declarations?

je

From: Pierre R. Mai
Subject: Re: defvar
Date: 
Message-ID: <87btcxdszt.fsf@orion.dent.isdn.cs.tu-berlin.de>
Josef Eschgfaeller <···@felix.unife.it> writes:

> Kent Pitman wrote (modified):
> 
> > (declaim '(inline ignore-please))
> > (defun ignore-please (&rest x) ; (*)
> >   (declare (ignore x)) nil)
> 
> Thank you. It works well, but I cannot understand why (ignore x)
> works, because x in this place should become a list, but it seems
> that normally I cannot write (declare (ignore '(x y))) or
> (declare (ignore (list x y))).

It seems to me, that you are confusing macros and functions.  The
ignore-please above is a _function_, so that the (declare (ignore x))
in it just states that the variable (or parameter) x itself is not
used, and should therefore be ignored.  What x is bound to at call
time doesn't matter at all.

In effect the normal ignoring part of ignore-please is done at call
time, where the compiler will see a call to a function with a certain
set of parameters, so it will assume that every parameter passed is
therefore used, and will not warn about them.  The (declare (ignore
x)) inside ignore-please, really only ensures that the compiler
doesn't warn about x itself, which would otherwise be unused.

You seem to think that the above ignore-please works like a macro,
i.e. something like

(defmacro ignore-please (&rest x)
  `(declare (ignore ,x)))

Appart from the fact that this is illegal for a number reasons anyway, 
and doesn't do what is intended, this whould exhibit the problem you
seem to be expecting, i.e. that

(ignore-please a b c)

would expand into

(declare (ignore (a b c)))

which would be illegal.  If you had defined the macro as

(defmacro ignore-please (&rest x)
  `(declare (ignore ,@x)))

then 

(ignore-please a b c)

would expand into

(declare (ignore a b c))

which would be "more" correct, but which would still not be legal,
because macros can't expand into declarations.  Also the function
works much better in a number of contexts, and is generally the right
thing...

Or perhaps you have an entirely different problem...

Regs, Pierre.

-- 
Pierre Mai <····@acm.org>         PGP and GPG keys at your nearest Keyserver
  "One smaller motivation which, in part, stems from altruism is Microsoft-
   bashing." [Microsoft memo, see http://www.opensource.org/halloween1.html]
From: Kent M Pitman
Subject: Re: defvar
Date: 
Message-ID: <sfwemht77t1.fsf@world.std.com>
Josef Eschgfaeller <···@felix.unife.it> writes:

> Kent Pitman wrote (modified):
> 
> > (declaim '(inline ignore-please))
> > (defun ignore-please (&rest x) ; (*)
> >   (declare (ignore x)) nil)
> 
> Thank you. It works well, but I cannot understand why (ignore x)
> works, because x in this place should become a list, but it seems
> that normally I cannot write (declare (ignore '(x y))) or

 (declare (ignore x y)) ;good

but NOT

 (declare (ignore '(x y))) ;BAD

which is the same as

 (declare (ignore (quote x y))) ;BAD

The syntax is (declare (ignore <var1> <var2> ..))

You also cannot write:

> (declare (ignore (list x y))).

Again because the ignore declaration takes symbols, not lists.

  (declare (ignore x y)) ;good
NOT
  (declare (ignore (list x y))) ;BAD



>   (defun f (&rest x) (declare (ignore x)) 7)
> 
> too is accepted by the compiler. But why?

Because it has only symbols after the word IGNORE (at the  same list level).
And because you are ignoring X.

 
>   (defun f (&rest x) (+ x x))
> 
> is obviously not allowed.

That's because this is a type error.  X is a list.  + takes numbers.

> What is the difference?
> It seems that, if I want to use it for only one
> variable, both x alone and &rest x in (*) are correct.

I don't know what you mean by (*) here.  Nor by "it".

How you say you want to add all the numbers, by the way, is like this:
 (defun f (&rest x) (apply #'+ x))
It doesn't seem relevant to this discussion, but it might somehow help you.

> Do I make a mistake, or is it a rule that one can use
> such short forms in declarations?

I don't think there's a longhand or shorthand rule here.
DECLARE takes a number of specific declarations.  The
IGNORE declaration has a definite syntax which you are violating.
Look up IGNORE in the Common Lisp HyperSpec.
http://www.harlequin.com/education/books/HyperSpec/FrontMatter/
Look in the Symbol Index, then under I.  You can basically
only ignore variable names and function names.  (You should probably
ignore the part about function names, though for now.  It doesn't
sound like you're ready to worry about that.)