From -4785037612906991943
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,c491eb430f6ab75a
X-Google-Attributes: gidf78e5,public
From: kuehl@uzwil.informatik.uni-konstanz.de (Dietmar Kuehl)
Subject: Re: How about #depricate
Date: 1997/02/24
Message-ID: <5enmfa$6nh$1@news.belwue.de>#1/1
X-Deja-AN: 221124300
References: <330B4E75.16FE@strata3d.com> <330CD371.2225@mds.rmit.edu.au> <5elr8j$mkq@mulga.cs.mu.OZ.AU>
X-Original-Date: 22 Feb 1997 20:55:06 GMT
Organization: Fakult�t f�r Mathematik und Informatik
X-Auth: PGPMoose V1.1 PGP comp.std.c++
Reply-To: dietmar.kuehl@uni-konstanz.de
Newsgroups: comp.std.c++
Originator: austern@isolde.mti.sgi.com


Hi,
Fergus Henderson (fjh@murlibobo.cs.mu.OZ.AU) wrote:
: Yes, compiler vendors do this sort of thing often.  The point of this
: extension would be to give library implementors the power to do the same.

But I don't really see, why this should be limited to deprecated
features (although this would be a start...):  I think, if something
like this is supposed to go into the language it should be a general
mechanism which may issue a warning. For example, I would like it if it
were possible to add extensions to the standard library, eg. the file
descriptor members to the IOStream library on UNIXes, and issue a
warning if the compiler is invoked with the correct options: Enabling
such warning would be reasonable for software which is supposed to be
portable while other software can just use these system specific
extensions. Then, the same mechanism can be used for deprecated
features, extensions, and so on.

Here is an example of what I think is a reasonable situation:

  class ostrstream warn(true, "use of 'ostrstream' is deprecated'")
  {
    // ...
  };

  class ofstream
  {
    // ...

    void attach(int fd) warn(STD_ONLY == 1, "'attach()' is a non-standard member");
  };

Of course, the messages could be improved but this is not the point.
The point is that this would yield a possibility to issue different
kinds of warnings depending on how some constant expressions evaluate:
If the first argument of 'warn', which has to be a constant expression,
yields 'true' the second argument is issued as messages if the
corresponding symbol is used. In the first case, the message that
'ostrstream' is deprecated is issued if this class is used. In the
second case, it is warned about 'attach()' being non-standard if
'STD_ONLY' evaluates to '1' and the attach member is used for an
'ofstream'.

I can imagine another bunch of potential warning which would make life
easier for library vendors and large developments. For example:

- Warn that a certain function/class is not yet completely implemented
  (of course, this should never be the case in a distributed library
  but may be reasonable during development)
- Warn about dependencies e.g. for objects with static linkage
- Warn about the use of a function which has a superior equivalent
  (e.g. use of 'qsort()' instead of 'sort()')

Although I think that issuing warnings about deprecated features of
standard components is a reasonable thing, I think that if something in
this direction is added to the standard, it should be more general. In
fact, a standard conforming C++ compiler is free to issue warnings
about use of deprecated features of the library anyway (since it may
issue whatever diagnostic it want as long as it compiles standard
conformant code and issues the required diagnostics) and there would be
no need to add anything to the standard.
--
<mailto:dietmar.kuehl@uni-konstanz.de>
<http://www.informatik.uni-konstanz.de/~kuehl/>
I am a realistic optimist - that's why I appear to be slightly pessimistic
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu 
]



