This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: Converting GCC to compilation with C++
- From: "Gabriel Dos Reis" <gdr at acm dot org>
- To: "Dave Korn" <dk at artimi dot com>
- Cc: gdr at acm dot org, "'Robert Dewar'" <dewar at gnat dot com>,"'Kai Henningsen'" <kaih at khms dot westfalen dot de>, gcc at gcc dot gnu dot org
- Date: Wed, 14 Jul 2004 19:38:09 +0200 (CEST)
- Subject: RE: Converting GCC to compilation with C++
- References: <32966.::ffff:24.250.169.187.1089817583.squirrel@webmail.nerim.net> <NUTMEGSmLAztxc1o8yf000008a6@NUTMEG.CAM.ARTIMI.COM>
- Reply-to: gdr at acm dot org
Dave Korn:
>> -----Original Message-----
>> From: gcc-owner On Behalf Of Gabriel Dos Reis
>> Sent: 14 July 2004 16:06
>
>> One difference between the "hooks" and virtual functions
>> is that the function pointer can get reset to something else
>> (contrary to virtual functions which get set in the constructor
>> by the compiler, one for ever) and we do not have a way to enforce
>> the invariant that the hook should be set once.
>
> Well, you could always declare the function pointer const and statically
> initialise it.
One could, except that initializations in GCC cases are dynamic,
and some happen only after some values have been succefully
computed.
> And on the other hand, there might be legitimate occasions for changing
> where a hook points to at runtime.
Yes, but for most uses of "hooks" in GCC, that is not the case.
For the remaining cases, where that re-assignment would be
required for legitimate reasons, pointers to functions naturally
suggest themselves -- even in C++! But, that is not the
majority of the cases.
-- Gaby