Re: [ROOT] const correctness request for TKey and ROOT classes

From: Rene Brun (Rene.Brun@cern.ch)
Date: Tue Nov 14 2000 - 09:10:16 MET


Hi Matt,
We agree with the principle to make root more "const correct".
This has already been mentionned a few times in this list (George H. in
particular).
However, as you say, this implies a non compatible interface.
We are currently discussing a major upgrade of the Root system (a version 3.0).
This new version will include an important upgrade of the Root I/O system with:
  - the introduction of an automatic schema evolution facility
  - extended support for more C++ constructs.
  - Full support for STL
  - self-describing file format
  - automatic regeneration of the class code from the dictionary in the file.
All these new features are currently implemented in our private development
version. Wew are now in a testing phase with large applications.

We could take this opportunity to review the interface.

Rene Brun

Matthew D. Langston wrote:
> 
> Hi ROOT Team,
> 
> I continually run into a lot of situations where I have to use const_cast on
> pointers to objects of ROOT classes in order to get my code to compile.  May
> I request that all of the getters be changed to const member functions in
> the ROOT classes please where it makes sense?
> 
> For a specific example of where this can easily bite a developer, I have
> some very old ROOT code that I was just hacking on that calls TKey::GetName
> (which is inherited from TNamed).  I needed to go back and change a small
> piece of this legacy code to get the cycle number of the TKey in addition to
> its name.  However, calling TKey::GetCycle() caused my C++ compiler to spew
> out pages and pages of const errors from the legacy code.
> 
> The problem was that this legacy code is passed a "const TKey*" (to insure,
> for safety reasons, that it doesn't change the TKey).  However,
> TKey::GetCycle  (and most of the other getters in TKey) are non-const member
> functions.  The work around was that I had to violate const correctness for
> large pieces of my legacy code.
> 
> I was about to go through all of the ROOT base classes that my legacy code
> depends on and change the getters to const member functions, and send you a
> patch of the differences.  However, I wanted to check with you first, as I
> didn't want to go to the trouble of making such sweeping changes if you
> wouldn't accept them for reasons that I might not currently appreciate.
> 
> Would you mind commenting in this please?  Do you think my proposal of
> making ROOT more const correct is a good idea?  If so, would you prefer to
> do the changes instead of receiving a patch from me?
> 
> I should point out that my proposed changes will constitute breaking the
> ROOT interfaces for all previous releases of ROOT, and would therefore break
> all user code for future releases ROOT.  However, I would argue that my
> proposed "const correct" changes would break code that should be broken, and
> would make ROOT, and all user code that depends on ROOT, more robust and
> stable.
> 
> Thank you for considering these changes.
> 
> Regards, Matt
> 
> --
> Matthew D. Langston
> SLD, Stanford Linear Accelerator Center
> langston@SLAC.Stanford.EDU



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:37 MET