ned@pebbles.cad.mcc.com (Ned Nowotny) (02/10/90)
What, if anything, is special about typedefs which are enclosed within a class declaration? G++ 1.36.4 does not recognize typedef names outside the scope of an enclosing class declaration and I am not enough of a language lawyer to know whether this is really a problem. I do know, however, that you can't declare something as a classname::typedef. Therefore, it would seem that G++'s behavior is either a bug, or typedefs within class declarations are nearly useless. Ned Nowotny, MCC CAD Program, Box 200195, Austin, TX 78720 Ph: (512) 338-3715 ARPA: ned@mcc.com UUCP: ...!cs.utexas.edu!milano!cadillac!ned ------------------------------------------------------------------------------- "We have ways to make you scream." - Intel advertisement in the June 1989 DDJ.
rfg@ics.uci.edu (Ronald Guilmette) (02/10/90)
In article <6016@cadillac.CAD.MCC.COM> ned@MCC.COM (Ned Nowotny) writes: >What, if anything, is special about typedefs which are enclosed within a class >declaration? G++ 1.36.4 does not recognize typedef names outside the scope >of an enclosing class declaration and I am not enough of a language lawyer >to know whether this is really a problem. Currently, g++ treats class-nested typedefs as local to the containing class. This is certainly different from what cfront 2.0 currently does. Whether it is a problem or not depends on what you are trying to do. Little incompatabilities like this are always mildly irritating however. I have mentioned this difference to MDT and I believe that he is disinclined to change the g++ treatement at this time. Part of his reasoning may be that there have been some suggestions made regarding rule changes for class- nested types. I think he would prefer to wait and see what happens there. (But I should not be speaking for him.) >I do know, however, that you >can't declare something as a classname::typedef. Therefore, it would seem that >G++'s behavior is either a bug, or typedefs within class declarations are >nearly useless. They may be useful within the class. Think encapsulation! // rfg
ned@pebbles.cad.mcc.com (Ned Nowotny) (02/12/90)
In article <25D3DCB8.16923@paris.ics.uci.edu> rfg@ics.uci.edu (Ronald Guilmette) writes: =>In article <6016@cadillac.CAD.MCC.COM> ned@MCC.COM (Ned Nowotny) writes: =>>...[ I question the way G++ handles typedefs within a class declaration ]... => =>Currently, g++ treats class-nested typedefs as local to the containing =>class. This is certainly different from what cfront 2.0 currently does. =>Whether it is a problem or not depends on what you are trying to do. =>Little incompatabilities like this are always mildly irritating however. => =>...[ Ron reports MDT's opinion on this issue ]... => =>>I do know, however, that you =>>can't declare something as a classname::typedef. Therefore, it would seem that =>>G++'s behavior is either a bug, or typedefs within class declarations are =>>nearly useless. => =>They may be useful within the class. Think encapsulation! => Now, I may just be ignorant, but it seems to me that encapsulation should mean that a private member function of a class could be declared and defined to return a type named by a typedef declared within a class declaration. However, G++ will not even allow this. (For an example, look at the parseDate function declared in Date.h and defined in Date.c in the NIH Class Library.) This variance from both C++ and ANSI C behavior seems unnecessary and, perhaps, incorrectly implemented. Ned Nowotny, MCC CAD Program, Box 200195, Austin, TX 78720 Ph: (512) 338-3715 ARPA: ned@mcc.com UUCP: ...!cs.utexas.edu!milano!cadillac!ned ------------------------------------------------------------------------------- "We have ways to make you scream." - Intel advertisement in the June 1989 DDJ.