Topic: Namespace nightmare?


Author: herbthom@nbnet.nb.ca (Herb Thompson)
Date: 19 May 1994 19:41:53 GMT
Raw View
In article <1994May15.181650.2420@nlm.nih.gov> bkline%occs.nlm.nih.gov (Bob Kline) writes:
>From: bkline%occs.nlm.nih.gov (Bob Kline)
>Subject: Namespace nightmare?
>Date: Sun, 15 May 94 18:16:50 GMT
>I just got to chapter 17 in _The Design and Evolution of C++_ (the
>chapter on namespaces).  When I hit section 17.4.2, "Getting

Could you post the name of the publisher and the ISBN number for this book?

Regards,
  Herb Thompson




Author: bkline%occs.nlm.nih.gov (Bob Kline)
Date: Fri, 20 May 94 01:41:07 GMT
Raw View
Herb Thompson (herbthom@nbnet.nb.ca) wrote:
: >I just got to chapter 17 in _The Design and Evolution of C++_ (the
: >chapter on namespaces).  When I hit section 17.4.2, "Getting

: Could you post the name of the publisher and the ISBN number for this book?


Sure: Addison-Wesley, ISBN 0-201-54330-3.  Recommended!


/*----------------------------------------------------------------------*/
/* Bob Kline                                           CSI Technologies */
/* bkline@smtp.csof.com                        Corporate Software, Inc. */
/* voice: (703) 522-0820                            fax: (703) 522-5407 */
/*----------------------------------------------------------------------*/




Author: maxtal@physics.su.OZ.AU (John Max Skaller)
Date: Sun, 15 May 1994 22:52:51 GMT
Raw View
In article <1994May15.181650.2420@nlm.nih.gov> bkline%occs.nlm.nih.gov (Bob Kline) writes:
>I just got to chapter 17 in _The Design and Evolution of C++_ (the
>chapter on namespaces).  When I hit section 17.4.2, "Getting
>Namespaces into Use" I had a very unpleasant vision of all my C++
>code breaking as soon as what Dr. Stroustrup is recommending gets
>implemented.  If I understand what he's recommending, all the
>ANSI C standard library calls will be placed in a new namespace.
>This means (again assuming I understand how namespaces work)
>that all those calls that I very carefully prepended with the
>global scope operator will no longer work.

The following solution is being considered:

 #include <stdlib.h>

will expand to something like:

 #include <stdlib>
 using std::malloc;
 ...

so that

 ::malloc(10)

will still work.

--
        JOHN (MAX) SKALLER,         INTERNET:maxtal@suphys.physics.su.oz.au
 Maxtal Pty Ltd,      CSERVE:10236.1703
        6 MacKay St ASHFIELD,     Mem: SA IT/9/22,SC22/WG21
        NSW 2131, AUSTRALIA




Author: bs@alice.att.com (Bjarne Stroustrup)
Date: 16 May 94 01:55:19 GMT
Raw View

bkline%occs.nlm.nih.gov (Bob Kline @ National Library of Medicine) writes

 >   The fact that Dr. Stroustrup makes no
 > mention of the potential problem (when he usually bends over
 > backwards to meticulously enumerate all the possible difficulties
 > which might arise from a proposal he is making) leads me think
 > that I'll wake up and find this was just a bad dream.  Anybody
 > want to speed up the process by pointing out what I've missed?

The ANSI C++ WP uses using-declarations to place names from the
standard C library in the global space if you use <stdio.h>.
This is clumbsy, but it makes ::strlen(p) work as ever.

 - Bjarne

 > :->}
:-)




Author: pete@genghis.interbase.borland.com (Pete Becker)
Date: Mon, 16 May 1994 16:52:01 GMT
Raw View
In article <1994May15.181650.2420@nlm.nih.gov>,
Bob Kline <bkline%occs.nlm.nih.gov> wrote:
>I just got to chapter 17 in _The Design and Evolution of C++_ (the
>chapter on namespaces).  When I hit section 17.4.2, "Getting
>Namespaces into Use" I had a very unpleasant vision of all my C++
>code breaking as soon as what Dr. Stroustrup is recommending gets
>implemented.  If I understand what he's recommending, all the
>ANSI C standard library calls will be placed in a new namespace.
>This means (again assuming I understand how namespaces work)
>that all those calls that I very carefully prepended with the
>global scope operator will no longer work.  I don't think I
>made up this technique of explicitly identifying the standard
>library functions as global, either.  Let's see, ..., here we
>are in the first book that comes to hand -- Tony Hansen's C++
>Answer Book uses this technique frequently.
>

 The standard header files will contain the appropriate using directives
so that existing code won't break. There will also be a parallel set of headers
that don't have any using directives, so you can get the full benefit of
namespaces.
 -- Pete




Author: bkline%occs.nlm.nih.gov (Bob Kline)
Date: Sun, 15 May 94 18:16:50 GMT
Raw View
I just got to chapter 17 in _The Design and Evolution of C++_ (the
chapter on namespaces).  When I hit section 17.4.2, "Getting
Namespaces into Use" I had a very unpleasant vision of all my C++
code breaking as soon as what Dr. Stroustrup is recommending gets
implemented.  If I understand what he's recommending, all the
ANSI C standard library calls will be placed in a new namespace.
This means (again assuming I understand how namespaces work)
that all those calls that I very carefully prepended with the
global scope operator will no longer work.  I don't think I
made up this technique of explicitly identifying the standard
library functions as global, either.  Let's see, ..., here we
are in the first book that comes to hand -- Tony Hansen's C++
Answer Book uses this technique frequently.

Frankly, this is the first new feature added to the language
for which I haven't yet seen the advantages which make it
overwhelmingly worthwhile.  I recall the pleasant surprise
I had when I was able to implement a moderately substantial
indexing library with the addition of only a single name (the
name of the top-level class) to the global name space.  Since
this experience, I don't have much sympathy for C++ library
vendors who claim they have so much difficulty avoiding
stepping on each other's toes (or global names).  I'm always
willing to be convinced, though (but not, I hope, at the
expense of having all the standard library calls whisked
away from where they've always been).

It's not unusual that I'll find that on subsequent readings
of technical explanations like this that I've missed something
on the first reading that, had I noticed it, would have caused
all the problems I first imagined to disappear.  I seriously
hope that this will happen with namespaces when I go back and
re-read the chapter.  The fact that Dr. Stroustrup makes no
mention of the potential problem (when he usually bends over
backwards to meticulously enumerate all the possible difficulties
which might arise from a proposal he is making) leads me think
that I'll wake up and find this was just a bad dream.  Anybody
want to speed up the process by pointing out what I've missed?
Thanks!

:->}

--
/*----------------------------------------------------------------------*/
/* Bob Kline                                           CSI Technologies */
/* bkline@smtp.csof.com                        Corporate Software, Inc. */
/* voice: (703) 522-0820                            fax: (703) 522-5407 */
/*----------------------------------------------------------------------*/