Article View: comp.std.c++
Article #2468Re: ??? static locals in inline functions ???
From: Fergus Henderson
Date: Wed, 08 Nov 1995 10:10
Date: Wed, 08 Nov 1995 10:10
65 lines
3473 bytes
3473 bytes
kaelin@bridge.com (Kaelin Colclasure) writes: >Dick Menninger <Dick.Menninger@DaytonOH.ATTGIS.COM> writes: > > Dick> A better way to look at this is to see that inline > Dick> behaves like const as they both default to internal scope. > Dick> I suspect this choice comes from applicability to member > Dick> functions. If you made inline default to external scope, > Dick> you would have difficulty changing that to internal scope > Dick> for member functions. Attaching static would have a rather > Dick> different semantics. However, having inline default to > Dick> internal scope allows extern to be applied without a change > Dick> of class-level semantics of the function. There has been some confusion of the three distinct concepts of scope (visibility), access, and linkage in this thread. Everywhere that Dick Menninger refers to "scope", he should be referring to "linkage". Roughly speaking, the distinction is as follows. Scope determines which name an identifier refers to. Linkage determines whether different occurrences of the same name (e.g. in different translation units) refer to the same entity. Access determines when it is legal for a particular name to be used. >Hmmm, I don't really understand how member functions enter into the >picture here. The visibility of member functions is determined a) by >the visibility of their enclosing class and b) by the explicit >public/protected/private visibility tag they are assigned. No, public/protected/private affect accessibility, not visibility. The two are different concepts in C++. >The concept of an "extern" member function is meaningless-- The concept of a member function with "extern" scope would be meaningless, but the concept of a member function having external linkage is quite meaningful. Indeed, all member functions have external linkage, except for member functions of local classes defined withing other functions, which have no linkage. >Your example of const variables defaulting to "file scope" is >something of a surprise to me as well. s/file scope/internal linkage/ >I recognize the obvious >benefit from a code generation perspective, but if this is true do we >ever expect anyone to learn this language (C++) without first >assimilating a massive body of historical and practical knowledge from >which to draw insight as to why these inconsistancies exist? I can't speak for anyone else, but I don't. I expect most people will learn some small subset of the language, and then muddle on. -- Fergus Henderson WWW: http://www.cs.mu.oz.au/~fjh fjh@cs.mu.oz.au PGP: finger fjh@128.250.37.3 --- [ 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:
<9531214.21952@mulga.cs.mu.OZ.AU>Path:
arc1-ca.pugleaf.net!news.mindlink.net!agate!agate!MattReferences:
<KAELIN.95Nov4090501@binki.bridge.com> <DHou9J.L8t@falcon.daytonoh.attgis.com> <KAELIN.95Nov7175431@binki.bridge.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!news.mindlink.net!agate!agate!Matt From: fjh@munta.cs.mu.OZ.AU (Fergus Henderson) Newsgroups: comp.std.c++ Subject: Re: ??? static locals in inline functions ??? Date: 08 Nov 1995 10:10:27 GMT Organization: Computer Science, University of Melbourne, Australia Approved: Matt@Austern Message-ID: <9531214.21952@mulga.cs.mu.OZ.AU> References: <KAELIN.95Nov4090501@binki.bridge.com> <DHou9J.L8t@falcon.daytonoh.attgis.com> <KAELIN.95Nov7175431@binki.bridge.com> NNTP-Posting-Host: austern.hip.berkeley.edu