[Openmcl-devel] how to ignore this warning? - shadows standard CL definition.
Pascal J. Bourguignon
pjb at informatimago.com
Sun Apr 15 12:47:54 PDT 2012
박성민 <byulparan at gmail.com> writes:
> [small-]
> I update to 1.9-dev-r15327M-trunk (DarwinX8664)!.
>
> I sometime shadow standard cl function.
>
> for example..
>
> (defmethod plus ((p1 number) (p2 number))
> (+ p1 p2))
>
> (defmethod plus ((p1 string) (p2 string))
> (concatenate 'string p1 p2))
>
> (labels ((+ (&rest rest)
> (reduce #'plus rest)))
> (+ "clozure" " common" " lisp"))
>
> ;Compiler warnings :
> ; In an anonymous lambda form: Local function or macro name + shadows standard CL definition.
> => "clozure common lisp"
>
> if I can ignore it, tell me what to do.... thank you.
You cannot ignore it, this is forbidden by the standard. You cannot, in
a conforming program, define a function with defun, labels or flet named
with a symbol from the CL package (and not only symbols defined by the
standard as functions, but ALL of them!)
* (flet ((*print-readably* () 'hi)) (*print-readably*))
is not conforming.
What you can do however, is to shadow the cl:+ symbol, and use your own
symbol named "+":
(defpackage "MY-PACKAGE"
(:use "CL")
(:shadow "+"))
(in-package "MY-PACKAGE)
(defun + (&rest args)
(apply (function cl:+) args))
(defmethod plus ((p1 string) (p2 string))
(concatenate 'string p1 p2))
(labels ((+ (&rest rest)
(reduce #'plus rest)))
(+ "clozure" " common" " lisp"))
is perfectly conforming: my-package::+ is not cl:+.
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.
More information about the Openmcl-devel
mailing list