🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2847

Re: using namespace std

#2847
From: Lassi A. Tuura
Date: Mon, 04 Dec 1995 22:32
73 lines
3683 bytes
David Vandevoorde <vandevod@cs.rpi.edu> writes:
> >>>>> "NM" == Nathan Myers <ncm@netcom.com> writes:
> [...]
> NM> Do those teaching C++ agree that namespace std encapsulation is a
> NM> failure?  When you write about C++, are you advising readers to
> NM> say "using namespace std;"?

It might be that I have totally misunderstood the concept of
namespaces since I haven't had any compiler to test them on.
I tried to read the relevant parts of the draft, and understood the
stuff as follows.

If I define a namespace like

namespace X {
   class XYZ { /* ... */ };
   extern XYZ xyz;
}

then I cannot cannot access `xyz' without additional scope qualifiers
until I have either "using namespace X;" or "using X::xyz;" in my
program.

Given that the standard namespace `std' is required to be declared
much like this, does the committee indeed assume that programmes would
be doing "using std::<a feature I need>;" instead of "using namespace
std;"?  I would say this is fairly bold assumption, and as such I
don't think the encapsulation will have much hopes for success.

> I wouldn't call it a failure, but I would like to see some ``topical''
> comparting so that I might write:
> 	using namespace ::std::strings;
> or
> 	using namespace ::std::vectors;
> etc. (I'm mentioning these two because I expect they often clash with
> existing names, unlike say ostream or valarray.)

This is exactly what I mean, and would very much like to see.  I am
quite confident that programmers like I will never have serious
clashes with the standard `std' name space.  However, the committee
should acknowledge that there are programmers that have better ways to
spend their time than trying to figure out all the using-declarations
they need.  These programmers are not usually computer scientists but
physicists or economists or you-name-it professionals who are using
the language as a means to achieve their needs: producing the
executable programs; the joy of writing c++ may not be their final
goal.

I see two possible paths emerging from the current situation:
  - programmers put "using namespace std;" in their programs, which
    will be *very* unfortunate; it will be hard to motivate them
    not to do so, at least not until the next revision is made to the
    standard and they have tons of clashes...
  - packages whose only purpose is to encapsulate std namespace
    features to smaller chunks will appear -- possibly (probably?)
    they will come directly with STL implementations.

Therefore, I propose the division David Vandevoorde mentioned should
be performed before the standard is finished.  Of course, this still
does not remove my original plea that the exceptions in the draft
standard should be named more uniformly.

//LaT
-- 
Lassi A. Tuura                           Have you not known?
Lassi.Tuura@hut.fi                       Have you not heard?


---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <l8220qk4oos.fsf@neppari.cs.hut.fi>
Path: arc1-ca.pugleaf.net!news.mindlink.net!agate!agate!Matt
References: <LASSI.TUURA.95Nov22175004@neppari.cs.hut.fi> <30BA21AC.4E9C@netcom.com> <VANDEVOD.95Nov28152659@avs.cs.rpi.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!news.mindlink.net!agate!agate!Matt
From: Lassi.Tuura@hut.fi (Lassi A. Tuura)
Newsgroups: comp.std.c++
Subject: Re: using namespace std
Date: 04 Dec 1995 22:32:42 GMT
Organization: Helsinki University of Technology, Finland
Approved: Matt@Austern
Message-ID: <l8220qk4oos.fsf@neppari.cs.hut.fi>
References: <LASSI.TUURA.95Nov22175004@neppari.cs.hut.fi>
 <30BA21AC.4E9C@netcom.com> <VANDEVOD.95Nov28152659@avs.cs.rpi.edu>
Reply-To: Lassi.Tuura@hut.fi
NNTP-Posting-Host: austern.hip.berkeley.edu