🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: type/member tags

#967
From: Ron Guilmette
Date: Mon, 25 Mar 1991 08:04
56 lines
2879 bytes
In article <1991Mar12.123811.13701@kodak.kodak.com> cok@islsun.Kodak.COM (David Cok) writes:
+In article <4338@lupine.NCD.COM> rfg@NCD.COM (Ron Guilmette) writes:
+>In article <27D3E544.619A@tct.uucp> chip@tct.uucp (Chip Salzenberg) writes:
+>+According to bill@robots.oxford.ac.uk (Bill Triggs):
+>+>Creation of an instance of an implicitly specified class....
+>+>It seems that an appropriately global `class-designator' is
+>+>indispensable for this, whether string or global address or
+>+>global enumeration constant ...
+>+
+>+The class name is already guaranteed to be unique (name equivalence
+>+and all that).  What need of more?
+>
+>Not only are file-scope class names not guaranteed to be unique across
+>multiple independent compilation units (which may later be combined to
+>form a single program) but class names need not even be unique *within*
+>a single compilation unit.  (Remember that any given compilation unit may
+>contain numerous independent declarative scopes.)
+>-- 
+
+I agree that class names can be reused in local scopes within functions and
+other classes.   But can they be reused at file scope in different 
+compilation units?

Why ask me?  Why not try it yourself?  You do have a C++ compiler (or
translator) don't you?

+I thought these were effectively global, as free
+functions are.

What is a "free function"?  I never heard of such a thing before.  Most
function I have seen are quite expensive. :-)

+If you try this with Sun C++ (and the classes happen to
+have non-inline functions with the same name and parameter types) you
+will get a link error with a multiply defined function error.

Yes.  On every other Thursday, if there is a full-moon and if a dog
is howling, you will get a link-time error.  In general however, you
will not.

+Not to
+necessarily advocate the use of a class name as a type tag, but it seems
+that it would work, with suitable mangling for local scopes, if one
+wanted to do it.

Well you could try to use tags a "globally" unique identifiers (across
compilation units) for their respective classes, but that would tend to
be unsafe.

I think that there are safer (and more efficient) ways to provide globally
unique "type identifiers" for class types.
-- 

// Ron ("Shoot From The Hip") Guilmette
// Internet: rfg@ncd.com      uucp: ...uunet!lupine!rfg
// New motto:  If it ain't broke, try using a bigger hammer.
Technical Details
Message-ID: <4626@lupine.NCD.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!decwrl!infopiz!lupine!rfg
References: <27D3E544.619A@tct.uucp> <4338@lupine.NCD.COM> <1991Mar12.123811.13701@kodak.kodak.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!decwrl!infopiz!lupine!rfg
From: rfg@NCD.COM (Ron Guilmette)
Newsgroups: comp.std.c++
Subject: Re: type/member tags
Message-ID: <4626@lupine.NCD.COM>
Date: 25 Mar 91 08:04:20 GMT
References: <27D3E544.619A@tct.uucp> <4338@lupine.NCD.COM> <1991Mar12.123811.13701@kodak.kodak.com>
Organization: Network Computing Devices, Inc., Mt. View, CA
Lines: 56