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