C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Re: Achieving virtualness from base class constructors

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards
View previous topic :: View next topic  
Author Message
Alf P. Steinbach
Guest





PostPosted: Mon Jul 19, 2004 2:06 pm    Post subject: Re: Achieving virtualness from base class constructors Reply with quote




* Alexander Terekhov:
Quote:

"Alf P. Steinbach" wrote:
[...]
One thing I don't see, immediately at least, is how to implement
"nonpoly" behavior,

?? "A class that declares or inherits a virtual function is called a
polymorphic class." Nonpoly thing would simply "disable" polymorphic
behavior (because it just can't be done right [current "cheating"
aside for a moment] during object construction and destruction).

Yes, how to do that (no matter where) is one thing I don't see about
how this proposal should work.


Quote:
and another, how that could be made to not break
assumptions in base classes (when their constructor have executed
successfully),

?? What assumptions?

For example, that in any Base member function a Base pure virtual
function can be called without UB.


Quote:
and a third, how to provide that in post-pre calls; i.e.,
what calls can be made, and how can they be be ensured to be non-poly?

struct T {

/* ... */

virtual void f() = 0;

void f1() nonpoly {
// (*this) is "T nonpoly"
f(); // ill-formed
}

void f2() {
// (*this) is "T poly"
}

T() {
// (*this) is "T nonpoly"
f1(); // OK
f2(); // ill-formed
}

post T() {
// (*this) is "T poly"
f1(); // OK
f2(); // OK
}

~T() throw() {
// (*this) is "T nonpoly"
f1(); // OK
f2(); // ill-formed
}

pre ~T() throw() {
// (*this) is "T poly"
// ...
}

};

or something like that ("poly_cast<>" aside for a moment).

I'm almost sure I'm now interpreting this incorrectly, but it seems that
by default _all_ calls a constructor can now make would in the new
scheme be ill-formed, thereby breaking all existing C++ code?

Btw., I suggest continuing this discussion in comp.std.c++, which I have
cross-posted this response to (i.e., I suggest removing the
comp.lang.c++.moderated group in any response).

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]



Back to top
Alexander Terekhov
Guest





PostPosted: Mon Jul 19, 2004 5:03 pm    Post subject: Re: Achieving virtualness from base class constructors Reply with quote




"Alf P. Steinbach" wrote:
[...]
Quote:
and a third, how to provide that in post-pre calls; i.e.,
what calls can be made, and how can they be be ensured to be non-poly?

struct T {

/* ... */

virtual void f() = 0;

void f1() nonpoly {
// (*this) is "T nonpoly"
f(); // ill-formed
}

void f2() {
// (*this) is "T poly"
}

T() {
// (*this) is "T nonpoly"
f1(); // OK
f2(); // ill-formed
}

post T() {
// (*this) is "T poly"
f1(); // OK
f2(); // OK
}

~T() throw() {
// (*this) is "T nonpoly"
f1(); // OK
f2(); // ill-formed
}

pre ~T() throw() {
// (*this) is "T poly"
// ...
}

};

or something like that ("poly_cast<>" aside for a moment).

I'm almost sure I'm now interpreting this incorrectly, but it seems that
by default _all_ calls a constructor can now make would in the new
scheme be ill-formed, thereby breaking all existing C++ code?

Almost (in the ctors and dtors of the polymorhic classes;
"compatibility" mode aside for a moment). How else would you close
that hole in the C++ type system? I'd suggest that people should
better ASAP start using POLY and NONPOLY empty defines. Wink ;-)

regards,
alexander.

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.