This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
gcc-4.0-virtual function return type
- From: JFanatiker <jfanatiker at yahoo dot de>
- To: gcc at gcc dot gnu dot org
- Date: Sun, 7 Nov 2004 21:36:45 +0100
- Subject: gcc-4.0-virtual function return type
Hi!
I read the current changes of gcc-4.0. There is the following in the C++ part:
G++ has an undocumented extension to virtual function covariance rules that
allowed the overrider to return a type that was implicitly convertable to the
overridden function's return type. For instance a function returning void *
could be overridden by a function returning T *. This is now deprecated and
will be removed in a future release.
-----------
Why are you going to throw away such good features like this one? This feature
is something greatly extending the object oriented programming. - A method of
a derived class can return a more specialised type as its parent- thats what
oop is all about!: Specialisation of a base class. (This greatly extends
polymorphism- very, very usefull!)
I'm thinking very much about an "Ideal programming language", I also thought
about this feature and considered it very good- now I read I can use this
with g++, but it is going to be removed- appalling.
Is it only because this feature isn't specified in the ISO standard?
Then I would consider the following solutions better:
- Suggest such good things to the iso committee
- Let extra features be only available with a compiler switch like
--enable-gnu-c++-extensions
or something like that, so that users can use them if they want- knowing
that this can cause portability problems.
With this switch available, there would be no boundaries! Every good idea
could be implemented. (Standards are good, but cumbersome)
I know that standards are very important, but if a developer knows he/she will
only compile his/her program with gcc, why shouldn't he/she be able to use
such features??
Or don't you think, this is a good feature?- If yes, why?
Thanks for your help!
Best regards,
Robert