Question about IGNORE:
(defun foo (x)
(declare (ignore x))
:ignored)
After compiling the function in KCl, I then do this:
>(foo)
:IGNORED
>(foo 1 2 3 4 5 6)
:IGNORED
Is this the right behavior? Should FOO complain about too many or too few
arguments, or can I count on this happening in all CL's? Steele doesn't
seem to have anything to say about it.
In article <····@phoenix.Princeton.EDU> ·····@phoenix.Princeton.EDU (Eliot Handelman) writes:
>Question about IGNORE:
>
>(defun foo (x)
> (declare (ignore x))
> :ignored)
>
>After compiling the function in KCl, I then do this:
>
>>(foo)
>:IGNORED
>
>>(foo 1 2 3 4 5 6)
>:IGNORED
>
>Is this the right behavior? Should FOO complain about too many or too few
>arguments, or can I count on this happening in all CL's? Steele doesn't
>seem to have anything to say about it.
As far as I know checks KCL the number of arguments only if you
declare (optimize (safety 2)) or (optimize (safety 3)). You can
declare that local with declare or global with proclaim. The default
is (safety 0). I don't think that the (declare (ignore x)) has
anything to do with the behavior.
Andreas Girgensohn
········@boulder.colorado.edu
In article <····@phoenix.Princeton.EDU> ·····@phoenix.Princeton.EDU (Eliot Handelman) writes:
>Question about IGNORE:
>
>(defun foo (x)
> (declare (ignore x))
> :ignored)
>
>Should FOO complain about too many or too few
>arguments, or can I count on this happening in all CL's? Steele doesn't
>seem to have anything to say about it.
The IGNORE declaration doesn't have anything to do with checking for the
right number of arguments. See CltL page 61: "there must be exactly
as many arguments as there are parameters". In other words, "it is
an error" if there aren't. Sometimes an error is signalled, sometimes
it's harmless, and sometimes Bad Things will happen. Some implementations
use OPTIMIZE declarations to decide whether to check for this error
in compiled code.
If you really want FOO to take any number of arguments and ignore them all,
try using:
(defun foo (&rest x)
(declare (ignore x))
:ignored)
-Sandra Loosemore (······@cs.utah.edu)
In article <····@phoenix.Princeton.EDU> ·····@phoenix.Princeton.EDU (Eliot Handelman) writes:
>(defun foo (x) > (declare (ignore x)) > :ignored)
(foo)
>:IGNORED
Allegro Lisp says "Too few arguments to FOO"
>(foo 1 2 3 4 5 6)
>:IGNORED
Allegro says "Too many arguments to FOO"
>Is this the right behavior? Should FOO complain about too many or too few
>arguments, or can I count on this happening in all CL's? Steele doesn't
>seem to have anything to say about it.
Perhaps the "right" or "wrong" behavior in this situation is yet another
little loophole in the CL spec, though I certainly believe the ACL
responses are more -helpful- than the ones you quote...
Marty Kent Sixth Sense Research and Development
415/642 0288 415/548 9129
·····@dewey.soe.berkeley.edu
{uwvax, decvax, inhp4}!ucbvax!mkent%dewey.soe.berkeley.edu
Kent's heuristic: Look for it first where you'd most like to find it.