I agree with Francois and Karthik :-)<br><br>I think that adding the assert Karthik suggested is a good idea even if we do proper input checking in the reader. If someone calls GetTuple() with an out-of-bounds index, the program is likely to misbehave or crash so  we might as well let the developer (not the end-user since asserts are compiled out in release builds) know that there is a bug somewhere.<br>
<br>I think that's a pre-condition. Is that right Francois?<br><br>-berk<br><br><div class="gmail_quote">On Sun, Feb 14, 2010 at 10:47 AM, Francois Bertel <span dir="ltr"><<a href="mailto:francois.bertel@kitware.com">francois.bertel@kitware.com</a>></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;">Asserts are for programming errors ONLY. Assert check if a programming<br>
is valid, bug free. It is just a very basic way in C++ to implement<br>
Programming by Contract<br>
<a href="http://en.wikipedia.org/wiki/Design_by_contract" target="_blank">http://en.wikipedia.org/wiki/Design_by_contract</a> (check of<br>
pre/post-conditions and invariants).<br>
<br>
<br>
They are NOT for checking the validity of the incoming data a program<br>
is loading or receiving. A program has to be robust regarding the<br>
input data (a file can be badly generated or can be corrupted because<br>
of a faulty block on a disk or an error in a remote connexion).<br>
<div><div></div><div class="h5"><br>
<br>
<br>
On Sun, Feb 14, 2010 at 8:58 AM, Karthik Krishnan<br>
<<a href="mailto:karthik.krishnan@kitware.com">karthik.krishnan@kitware.com</a>> wrote:<br>
> On Sat, Feb 13, 2010 at 6:18 PM, David Doria <<a href="mailto:daviddoria%2Bvtk@gmail.com">daviddoria+vtk@gmail.com</a>> wrote:<br>
>> to something like:<br>
>> template <class T><br>
>> void vtkDataArrayTemplate<T>::GetTuple(vtkIdType i, double* tuple)<br>
>> {<br>
>>   T* t = this->Array + this->NumberOfComponents*i;<br>
>>   if(!t)<br>
>>     {<br>
>>     return;<br>
>>     }<br>
><br>
> You could change that to : assert(t != NULL)<br>
><br>
> I think the VTK community would okay assert's. They compile only when<br>
> _DEBUG is defined; ie no overhead in the release version. That said,<br>
> Berk is right, that in this case it doesn't provide very useful<br>
> information..<br>
><br>
> Mimicking some of boost's compile time and static assertion's might be<br>
> good for VTK, to enable bounds checking and traits validity even in<br>
> performance critical code.<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>
><br>
<br>
<br>
<br>
</div></div><div class="im">--<br>
François Bertel, PhD  | Kitware Inc. Suite 204<br>
</div>1 (518) 371 3971 x113 | 28 Corporate Drive<br>
                      | Clifton Park NY 12065, USA<br>
<div><div></div><div class="h5">_______________________________________________<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>