Article View: comp.std.c++
Article #1477Re: Defining members of class T within cla
From: Steve Clamage
Date: Fri, 04 Aug 1995 16:28
Date: Fri, 04 Aug 1995 16:28
32 lines
1971 bytes
1971 bytes
In article pci@galaxy.ucr.edu, thp@PROBLEM_WITH_INEWS_DOMAIN_FILE (Tom Payne) writes: > >I'm voting "overworked compiler writers." > >C++ does not use C's single-pass semantics for names occurring within >a class. Specifically, the C++ "reconsideration rule" states: > > A name used in a class S must refer to the same declaration when > reevaluated in its context and in the completed scope of S, which > consists of the class S, S's base classes, and all classes enclosing > S. [D&E, p.142] The reconsideration rule requires at most two passes over a class, and a second pass generally makes other things easier to deal with anyway. Allowing use of an incomplete type, on the other hand, could require an arbitrary number of passes. The original example required postponing processing of a member type until the outer type was complete. This postponement could be required in principle to any number of levels. Instead of requiring this extra complexity in compilers, the language rule requires you to use complete types where complete type data is needed. The alternative would be to try to enumerate the cases where an incomplete type is allowed and and where it is not. Such a rule would be difficult to get right, difficult to understand and use. The current rule is simple. There is no difficulty in providing the definitions in the correct order, and I would argue that the resulting code is easier to read anyway. (You are entitled to a different opinion, of course.) --- Steve Clamage, stephen.clamage@eng.sun.com
Technical Details
Message-ID:
<3vthqo$m5t@engnews2.Eng.Sun.COM>Path:
arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!usenetReferences:
<3vrcu8$pci@galaxy.ucr.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!usenet From: clamage@Eng.Sun.COM (Steve Clamage) Newsgroups: comp.std.c++,comp.lang.c++ Subject: Re: Defining members of class T within cla Date: 4 Aug 1995 16:28:08 GMT Organization: Sun Microsystems Inc. Message-ID: <3vthqo$m5t@engnews2.Eng.Sun.COM> References: <3vrcu8$pci@galaxy.ucr.edu> Reply-To: clamage@Eng.Sun.COM NNTP-Posting-Host: taumet.eng.sun.com