From: Timofei Shatrov
Subject: Suppressing warnings for redefined functions
Date: 
Message-ID: <43105792.21259263@news.readfreenews.net>
I have a bunch of placeholder functions in one file that do almost
nothing. They are properly defined in another file. This results in a
large number of warnings that make it hard to see the real mistakes. Is
there a way to suppress these warnings, preferably only for the
functions of my choice?

-- 
|a\o/r|,-------------.,---------- Timofei Shatrov aka Grue ------------.
| m"a ||FC AMKAR PERM|| mail: grue at mail.ru  http://grue3.tripod.com |
|  k  ||  PWNZ J00   || Kingdom of Loathing: Grue3 lvl 18 Seal Clubber |
`-----'`-------------'`-------------------------------------------[4*72]

From: Pascal Costanza
Subject: Re: Suppressing warnings for redefined functions
Date: 
Message-ID: <3nb7moFn81hU1@individual.net>
Timofei Shatrov wrote:

> I have a bunch of placeholder functions in one file that do almost
> nothing. They are properly defined in another file. This results in a
> large number of warnings that make it hard to see the real mistakes. Is
> there a way to suppress these warnings, preferably only for the
> functions of my choice?

Use generic functions:

(defgeneric foo (x y z)
   (:method (x y z)
    (error "not defined yet")))

...and elsewhere:

(defmethod foo (x y z)
   ...)

You can also leave out the default method in the defgeneric form, but it 
might be easier to include it for better error handling.


Pascal

-- 
OOPSLA'05 tutorial on generic functions & the CLOS Metaobject Protocol
++++ see http://p-cos.net/oopsla05-tutorial.html for more details ++++
From: Nikonos
Subject: Re: Suppressing warnings for redefined functions
Date: 
Message-ID: <877je76zjl.fsf@abalone.chi-square-works.com>
Pascal Costanza <··@p-cos.net> writes:

> Timofei Shatrov wrote:
>
>> I have a bunch of placeholder functions in one file that do almost
>> nothing. They are properly defined in another file. This results in a
>> large number of warnings that make it hard to see the real mistakes. Is
>> there a way to suppress these warnings, preferably only for the
>> functions of my choice?
>
> Use generic functions:
>
> (defgeneric foo (x y z)
>   (:method (x y z)
>    (error "not defined yet")))
>
> ...and elsewhere:
>
> (defmethod foo (x y z)
>   ...)

What if you are not using generic functions?

Add the following:

(declaim (ftype Function ftn-to-be-defined-later-somewhere))

at a place before ftn-to-be-defined-later-somewhere is first called.

Best,

-cph
From: Barry Margolin
Subject: Re: Suppressing warnings for redefined functions
Date: 
Message-ID: <barmar-AFBD56.16462627082005@comcast.dca.giganews.com>
In article <··············@abalone.chi-square-works.com>,
 Nikonos <·······@comcast-the-hell-with-spammers.net> wrote:

> Pascal Costanza <··@p-cos.net> writes:
> 
> > Timofei Shatrov wrote:
> >
> >> I have a bunch of placeholder functions in one file that do almost
> >> nothing. They are properly defined in another file. This results in a
> >> large number of warnings that make it hard to see the real mistakes. Is
> >> there a way to suppress these warnings, preferably only for the
> >> functions of my choice?
> >
> > Use generic functions:
> >
> > (defgeneric foo (x y z)
> >   (:method (x y z)
> >    (error "not defined yet")))
> >
> > ...and elsewhere:
> >
> > (defmethod foo (x y z)
> >   ...)
> 
> What if you are not using generic functions?

A generic function that doesn't have any specializers (they all default 
to T) is effectively the same as an ordinary function.

However, the above is not guaranteed to suppress redefinition warnings.  
I can easily imagine an implementation warning that a method with the 
same specializers is being redefined in a different file.

There's probably an implementation-dependent flag that controls these 
warnings.  You didn't say what implementation you're using, so even if I 
knew the variables I wouldn't know which one to recommend to you.  Check 
your documentation, or do (apropos 'redefin) to see if you can find a 
variable that seems relevant.

-- 
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
From: Nikonos
Subject: Re: Suppressing warnings for redefined functions
Date: 
Message-ID: <87y86m63b4.fsf@abalone.chi-square-works.com>
Barry Margolin <······@alum.mit.edu> writes:

> In article <··············@abalone.chi-square-works.com>,
>  Nikonos <·······@comcast-the-hell-with-spammers.net> wrote:
>
>> Pascal Costanza <··@p-cos.net> writes:
>> 
>> > Timofei Shatrov wrote:
>> >
>> >> I have a bunch of placeholder functions in one file that do almost
>> >> nothing. They are properly defined in another file. This results in a
>> >> large number of warnings that make it hard to see the real mistakes. Is
>> >> there a way to suppress these warnings, preferably only for the
>> >> functions of my choice?
>> >
>> > Use generic functions:
>> >
>> > (defgeneric foo (x y z)
>> >   (:method (x y z)
>> >    (error "not defined yet")))
>> >
>> > ...and elsewhere:
>> >
>> > (defmethod foo (x y z)
>> >   ...)
>> 
>> What if you are not using generic functions?
>
> A generic function that doesn't have any specializers (they all default 
> to T) is effectively the same as an ordinary function.
>
> However, the above is not guaranteed to suppress redefinition warnings.  
> I can easily imagine an implementation warning that a method with the 
> same specializers is being redefined in a different file.

Actually, I did not suggest (DECLAIM (FTYP FUNCTION ...)) to SUPPRESS
redefinition warnings.  I suggested it to AVOID redefining a bunch of 
functions.  I believe Pascal suggested DEFGENERIC for the same reason.
For Timofei to solve his problem, just replace those placeholder functions
with a bunch of DEFGENERIC or (DECLAIM (FTYPE FUNCTION ...)) and be happy.

This works for me on CMUCL.

Cheers,

-cph
From: Barry Margolin
Subject: Re: Suppressing warnings for redefined functions
Date: 
Message-ID: <barmar-FD5B8A.21172928082005@comcast.dca.giganews.com>
In article <··············@abalone.chi-square-works.com>,
 Nikonos <·······@comcast-the-hell-with-spammers.net> wrote:

> Barry Margolin <······@alum.mit.edu> writes:
> 
> > In article <··············@abalone.chi-square-works.com>,
> >  Nikonos <·······@comcast-the-hell-with-spammers.net> wrote:
> >
> >> Pascal Costanza <··@p-cos.net> writes:
> >> 
> >> > Timofei Shatrov wrote:
> >> >
> >> >> I have a bunch of placeholder functions in one file that do almost
> >> >> nothing. They are properly defined in another file. This results in a
> >> >> large number of warnings that make it hard to see the real mistakes. Is
> >> >> there a way to suppress these warnings, preferably only for the
> >> >> functions of my choice?
> >> >
> >> > Use generic functions:
> >> >
> >> > (defgeneric foo (x y z)
> >> >   (:method (x y z)
> >> >    (error "not defined yet")))
> >> >
> >> > ...and elsewhere:
> >> >
> >> > (defmethod foo (x y z)
> >> >   ...)
> >> 
> >> What if you are not using generic functions?
> >
> > A generic function that doesn't have any specializers (they all default 
> > to T) is effectively the same as an ordinary function.
> >
> > However, the above is not guaranteed to suppress redefinition warnings.  
> > I can easily imagine an implementation warning that a method with the 
> > same specializers is being redefined in a different file.
> 
> Actually, I did not suggest (DECLAIM (FTYP FUNCTION ...)) to SUPPRESS
> redefinition warnings.  I suggested it to AVOID redefining a bunch of 
> functions.  I believe Pascal suggested DEFGENERIC for the same reason.

But the code quoted above *does* redefine the function.  The method is 
defined first in the file containing the DEFGENERIC, and then redefined 
in the file containing the DEFMETHOD.

Perhaps if the :METHOD option to DEFGENERIC were omitted then it would 
quiet all implementations.

-- 
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
From: Thomas A. Russ
Subject: Re: Suppressing warnings for redefined functions
Date: 
Message-ID: <ymiwtm4egy4.fsf@sevak.isi.edu>
Barry Margolin <······@alum.mit.edu> writes:

> > > Timofei Shatrov wrote:
> > >
> > >> I have a bunch of placeholder functions in one file that do almost
> > >> nothing. They are properly defined in another file. This results in a
> > >> large number of warnings that make it hard to see the real mistakes. Is
> > >> there a way to suppress these warnings, preferably only for the
> > >> functions of my choice?

> There's probably an implementation-dependent flag that controls these 
> warnings.  You didn't say what implementation you're using, so even if I 
> knew the variables I wouldn't know which one to recommend to you.  Check 
> your documentation, or do (apropos 'redefin) to see if you can find a 
> variable that seems relevant.

Yes, this really is the crux of the matter.  There isn't any really
portable way to do this.  Looking back at our Loom files, what I did was
to identify at least some of the language features that are used and
then encode them into a set of macro definitions:


#+:MCL
(defmacro with-redefinition-warnings-suppressed (&body forms)
  ;; Wrap form with code to suppress redefinition warnings
  `(let ((CCL::*warn-if-redefine* nil))
     ,@forms ))

#+:EXCL
(defmacro with-redefinition-warnings-suppressed (&body forms)
  ;; Wrap form with code to suppress redefinition warnings
  `(let ((EXCL::*redefinition-warnings* nil))
     ,@forms ))

#+:ACLPC
(defmacro with-redefinition-warnings-suppressed (&body forms)
  ;; Wrap form with code to suppress redefinition warnings
  `(let ((top::*warn-on-redefinition* nil))
     ,@forms ))

#+:LUCID
(defmacro with-redefinition-warnings-suppressed (&body forms)
  ;; Wrap form with code to suppress redefinition warnings
  `(let ((USER::*redefinition-action* nil))
     ,@forms ))

#+:TI
(defmacro with-redefinition-warnings-suppressed (&body forms)
  ;; Wrap form with code to suppress redefinition warnings
  `(let ((TICL::inhibit-fdefine-warnings t))
     ,@forms ))

#+:LISPWORKS
(defmacro with-redefinition-warnings-suppressed (&body forms)
  ;; Wrap form with code to suppress redefinition warnings
  `(let ((LISPWORKS::*redefinition-action* nil))
     ,@forms ))


#-(or :MCL :EXCL :ACLPC :LUCID :TI :LISPWORKS)
(defmacro with-redefinition-warnings-suppressed (&body forms)
  ;; Wrap form with code to suppress redefinition warnings
  ;; Default: Do nothing:
  `(progn ,@forms ))


-- 
Thomas A. Russ,  USC/Information Sciences Institute