[vtk-developers] Const correctness for string methods

Lorensen, William E (Research) lorensen at crd.ge.com
Mon Jan 19 14:36:42 EST 2004


Adding const-correctness can be very disruptive and invasive unless the code
considered it from the start. Witk ITK we tried to be const-correct from the
start and it certainly has been valuable.

We seem to be reaching an interesting point in vtk's development. Much more
refactoring of the core than new algortihm development. This seems to happen
to code after it reaches a cetain maturity. This may mean that Visualization
has matured. In fact, vtk has in many respects 'commoditized' visualization.


Bill

-----Original Message-----
From: Sebastien BARRE [mailto:sebastien at barre.nom.fr]
Sent: Monday, January 19, 2004 1:56 PM
To: David Thompson
Cc: Ken Martin; vtk-developers at public.kitware.com
Subject: RE: [vtk-developers] Const correctness for string methods


At 1/19/2004 10:36 AM, David Thompson wrote:
> > I don't think you can overload based on return value.
>You cannot, but the const-ness of the member function CAN be overloaded.
>For instance,
>
>         double* GetPoint( vtkIdType );
>         const double* GetPoint( vtkIdType ) const;

Const-correctness is a non-trivial topic in VTK: it's not that easy to 
really tell if a method should be const-correct or not depending on what is 
changed internally (for example). You could call a Get() method that  looks 
like a nice const-correct candidate, but have that Get() method trigger 
another method that legitimately modifies attributes internally to perform 
a computation (for example, bounds). Worst, you could have a chain of 
methods that are all const-correct, but one day you change one call in the 
final method, and that call has to be non-const, and then it breaks havoc 
all along the chain. If I remember that behaviour can be handled through 
'mutable' attributes (Brad), but I'm not sure we want to go that way...

_______________________________________________
vtk-developers mailing list
vtk-developers at vtk.org
http://www.vtk.org/mailman/listinfo/vtk-developers



More information about the vtk-developers mailing list