daniel@terra.ucsc.edu (Daniel Edelson) (08/16/90)
[E&S 90] section 12.4 says that when a destructor is explicitly called its name must be fully qualified: i.e., p->X::~X() rather than p->~X(). The relevant productions in this grammar (for an example that uses ->) are: expression ... cast-expression ... postfix-expression ... name name: qualified-name qualified-name: class-name :: ~ class-name Document X3J16/90-0032, ``Differences Between the C++ Reference Manuals'' (errata in the version of [E&S 90] that was distributed at the March 1990 X3J16 meeting) contradicts this. This document has the production name: ~ class-name This will permit an explicit call to the destructor without use of the fully qualified name. Is the revised document correct or is this an errata in the grammar in the errata list? Daniel Edelson daniel@cis.ucsc.edu (University of California, Santa Cruz) or ...!sun!practic!peren!daniel (Perennial Software, Inc.)
mjv@objects.mv.com (Michael J. Vilot) (08/18/90)
Daniel Edelson points out a change to the grammar: > [E&S 90] section 12.4 says that when a destructor is > explicitly called its name must be fully qualified The copy of the book I have does not state this restriction anywhere in section 12.4. The restriction is instead: ``An explicit call of a destructor must use -> or . explicitly. An attempt to rely on implicit use of the this pointer would lead to confusion between the use of the ~ as part of the name of the destructor and using the unary ~ operator'' and uses an example on page 279 to illustrate. In any event, the language is more than just the grammar. The qualified name is still available through the productions: name: qualified-name qualified-name: qualified-class-name :: name name: ~ class-name The usual semantic differentiations apply, and using the fully qualified name suppresses the dynamic binding of virtual functions. What may astound some people is the change on page 280: ``The notation for explicit call of a destructor may be used for any simple type name. For example, int* p; // ... p->int::~int();'' -- Mike Vilot, ObjectWare Inc, Nashua NH mjv@objects.mv.com (UUCP: ...!decvax!zinn!objects!mjv)
daniel@terra.ucsc.edu (Daniel Edelson) (08/21/90)
In article <867@zinn.MV.COM> mjv@objects.mv.com (Michael J. Vilot) writes: >Daniel Edelson points out a change to the grammar: >> [E&S 90] section 12.4 says that when a destructor is >> explicitly called its name must be fully qualified > >The copy of the book I have does not state this restriction anywhere in >section 12.4. The restriction is instead: > ``An explicit call of a destructor must use -> or . explicitly. An > attempt to rely on implicit use of the this pointer would lead to > confusion between the use of the ~ as part of the name of the > destructor and using the unary ~ operator'' >and uses an example on page 279 to illustrate. Page 279 of my book is part of section 12.8, copying objects. Perhaps I have a pre-publication version. In my copy the annotations of section 12.4 contain ``the fully qualified form of the destructor's name must be used to avoid confusion between the use of the ~ as part of the name of the destructor and the unary ~ operator as described in 5.3'' However the document X3J16-0032 contradicts this. I've been told from shopiro@research.att.com that p->~X() is legal, my version of the ARM appears to be pre-publication. >Mike Vilot, ObjectWare Inc, Nashua NH >mjv@objects.mv.com (UUCP: ...!decvax!zinn!objects!mjv) Daniel Edelson daniel@cis.ucsc.edu or sun!practic!peren!daniel (Perennial Software, Inc.)