Tom:<br><br>Isn&#39;t this too pervasive a change ? Its perfect if this change was restricted to non-virtual methods, private class members, static methods and private implementations in CXX files.<br><br>I can think of several projects that depend on VTK choking at a change like this :<br>
<br>   <a href="http://review.source.kitware.com/#patch,sidebyside,881,1,Widgets/vtkWidgetRepresentation.h">http://review.source.kitware.com/#patch,sidebyside,881,1,Widgets/vtkWidgetRepresentation.h</a><br><br>Thanks<br>--<br>
karthik<br><br><div class="gmail_quote">On Thu, Feb 10, 2011 at 11:55 PM, tom fogal <span dir="ltr">&lt;<a href="mailto:tfogal@sci.utah.edu">tfogal@sci.utah.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">Berk Geveci &lt;<a href="mailto:berk.geveci@kitware.com">berk.geveci@kitware.com</a>&gt; writes:<br>
&gt; Hi Tom,<br>
&gt;<br>
&gt; Am I correct in assuming that almost every single subclass of VTK in<br>
&gt; other projects will fail to compile after this change?<br>
<br>
</div>Not every class, no.  Of course, things that were const and are no<br>
longer will complain about overloads being invalid.<br>
<br>
I do not think it will be as bad as the float-&gt;double conversion, but<br>
it will be up there.<br>
<div class="im"><br>
&gt; Are there any other backwards compatibility implications of this?<br>
<br>
</div>Not that I can think of.  Someone else brought up the Python issue, see<br>
the other mails in this thread; I haven&#39;t had a chance to look into<br>
that yet.<br>
<div class="im"><br>
&gt; Also, what are the advantages of this change?<br>
<br>
</div>Those of us that are downstream run into a lot of problems because of<br>
VTK&#39;s lack of const.  A very well-behaved project could const_cast<br>
things all over the place, but I doubt anyone does this in practice; in<br>
reality the lack of const just infects others&#39; codebases.<br>
<br>
It&#39;s also an issue when one has multiple libraries and data<br>
from one needs to interop with VTK: try pulling out a list of<br>
constant-somethings from Qt and then populating a VTK object with the<br>
data, for example.<br>
<br>
As to const in general -- it&#39;s a very useful mechanism for keeping a<br>
mental image of large sets of code.  It is much easier to reason about<br>
code when you know a method call, for example, is const.  I can already<br>
hear the &quot;but I *know* GetCell is const!&quot; arguments, so I&#39;d like to<br>
shut them down with: sure you do, but 1) the people on this list are<br>
predispositioned to know a lot about how VTK works, 2) the existing<br>
setup provides no guarantees in the face of code evolution, and 3)<br>
infinitely mutable state makes a system more difficult to reason about;<br>
the status quo scales poorly to larger bodies of code.<br>
<br>
The C++ FAQ has more information:<br>
<br>
  <a href="http://www.parashift.com/c++-faq-lite/const-correctness.html" target="_blank">http://www.parashift.com/c++-faq-lite/const-correctness.html</a><br>
<div class="im"><br>
&gt; Also it doesn&#39;t look like you attempted to mark const functions as<br>
&gt; such. Was that because it was too hard?<br>
<br>
</div>Well, &quot;yes&quot;, but &quot;hard&quot; is pretty relative, see below.<br>
<div class="im"><br>
&gt; This is probably a naive question because I admit that I don&#39;t have a<br>
&gt; good grasp of constant functions. For example, couldn&#39;t this function<br>
&gt; be const?<br>
&gt;<br>
&gt; in vtkDataSet:<br>
&gt;   virtual void GetCell(vtkIdType cellId, vtkGenericCell *cell) = 0;<br>
&gt;<br>
&gt; This GetCell() does not change any data member of the dataset.<br>
<br>
</div>Probably.  You would have to look in the implementation of every<br>
derived classes&#39; GetCell method and ensure it does not modify the<br>
object.  My guess is that you are correct, and it would be good to mark<br>
GetCell as const, but I have not verified.  Patch, please? :)<br>
<br>
The issue is that GetCell probably calls some LookupCell method<br>
or something like that (i&#39;m making up method names).  That method<br>
might not be const, even though it doesn&#39;t modify anything.  In all<br>
likelihood, it&#39;s probably virtual too, and so you need to verify that<br>
all derived classes&#39; LookupCell methods don&#39;t modify anything.  But<br>
then in, say, vtkUnstructuredGrid, LookupCell happens to call XYZ, a<br>
virtual method which isn&#39;t marked const, but is ...<br>
<br>
In short: adding these in is very, very easy.  I did a lot of this with<br>
sed scripts.  But it&#39;s also incredibly tedious and eats up lots of<br>
time.<br>
<br>
To get full support, someone would need to read every single line of<br>
VTK and think about const.  That&#39;s not feasible for me to do (hence the<br>
&quot;Well, mostly&quot; in my original email).  It would probably be feasible<br>
for a concerted effort, but emails like yours make me wonder if I could<br>
drum up enough support from the developer base :)<br>
<font color="#888888"><br>
-tom<br>
</font><div><div></div><div class="h5"><br>
&gt; On Mon, Feb 7, 2011 at 5:56 PM, tom fogal &lt;<a href="mailto:tfogal@sci.utah.edu">tfogal@sci.utah.edu</a>&gt; wrote:<br>
&gt;<br>
&gt; &gt; I have just pushed a new branch, `const-correctness&#39;, to my git repo:<br>
&gt; &gt;<br>
&gt; &gt;  git://<a href="http://shigeru.sci.utah.edu/vtk.git" target="_blank">shigeru.sci.utah.edu/vtk.git</a><br>
&gt; &gt;<br>
&gt; &gt; As you might guess, this makes VTK const correct.  Well, mostly.<br>
&gt; &gt;<br>
&gt; &gt; I had to fix the wrapper-parsing code a bit.  I&#39;ve tested the<br>
&gt; &gt; python wrappings thus far.  They all use the same parser, right?<br>
&gt; &gt; Anybody want to test / potentially fix up TCL and/or Java for me?<br>
&gt; &gt; Should be easy, given that the Python stuff already works....<br>
&gt; &gt;<br>
&gt; &gt; I&#39;ll start rebasing against VTK master after this email.  This will<br>
&gt; &gt; get out of date fast (and thus be a pain to maintain), so I hope we<br>
&gt; &gt; can push it through soon.<br>
&gt; &gt;<br>
&gt; &gt; -tom<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtk-developers" target="_blank">http://www.vtk.org/mailman/listinfo/vtk-developers</a><br>
<br>
</div></div></blockquote></div><br>