This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Converting GCC to compilation with C++


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]