Path: utzoo!attcan!uunet!pilchuck!dataio!bright From: bright@Data-IO.COM (Walter Bright) Newsgroups: comp.lang.c++ Subject: Re: Any interest in making C++ a real superset of ANSI C? Message-ID: <1997@dataio.Data-IO.COM> Date: 26 May 89 18:36:32 GMT References: <7435@hoptoad.uucp> Reply-To: bright@dataio.Data-IO.COM (Walter Bright) Organization: Data I/O Corporation; Redmond, WA Lines: 34 In article <7435@hoptoad.uucp> gnu@hoptoad.uucp (John Gilmore) writes: >But the gross change that makes "struct foo {...};" >equivalent to "typedef struct foo {...} foo;" is too much to bear. >Surely the burden of incompatability is too high a price to pay, when >the solution is simple: either writing "struct/union/class/enum foo" >when you declare a "foo", or explicitly coding a typedef yourself in >the header file. There's an even easier solution. I've proposed it to Bjarne, but he disliked it on the grounds that it would require some reediting of existing C++ code. The solution is to retain the separate tag name space for structs and unions, but use the regular name space for class names. Thus, if you declare a struct as 'struct A', you always have to use 'struct A' when referring to A. If you declare it as 'class A', then the typedef is created. For example: struct A { int abc; void fA(); }; class B { int def; void fB(); }; struct A var1; B var2; void struct A::fA() { abc = 3; } void B::fB() { def = 4; } I haven't explored all the ramifications of this, but it looks straightforward. I'm also of the opinion that if you use C++ features in an aggregate, it should be called a 'class'. If it only uses C features, it should be called 'struct'. I'd even support having the compiler enforce this. I'm interested in other's opinions on this.