<div class="gmail_quote">On Fri, Jan 8, 2010 at 4:08 PM, Marcus D. Hanwell <span dir="ltr"><<a href="mailto:marcus.hanwell@kitware.com">marcus.hanwell@kitware.com</a>></span> wrote:<br><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im"><snip></div></blockquote><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">I would like to add my -1, I think needing to split lines in order to declare</div>

a new local variable is a little much. I came from a C++ background where any<br>
object could be declared on the stack though. For things like the examples it<br>
seems to hurt readability to me.<br>
<br>
Pointer:<br>
vtkFloatArray *myTable = vtkFloatArray::New();<br>
myTable->Delete();<br>
myTable = NULL;<br>
<br>
Smart pointer:<br>
vtkSmartPointer<vtkFloatArray> myTable =<br>
     vtkSmartPointer<vtkFloatArray>::New();<br>
<br>
Smart pointer with macro:<br>
VTK_CREATE(vtkFloatArray, myTable);<br>
<br>
Stack:<br>
vtkFloatArray myTable;<br>
<br>
I would prefer to be able to use something like the first or the last. In<br>
classes etc it is often a different story. It seems like there should be some<br>
macro or template function to generate variables with less repetition.<br>
<br></blockquote><div><br></div><div>Prefer the first and last as much as you want, but we simply can't use them in VTK. The first leads to memory leaks because people forget the Delete calls. The last cannot be done with vtkObject derived classes because of the nature of vtkObject reference counting...</div>
<div><br></div><div>So we have to pick one of the middle ones...</div><div><br></div><div>It's unfortunate that we've had two +1's and two -1's... that leaves us at 0 for the moment. I guess that and the fact that it's Friday makes it fairly easy to put off a decision until at least next week. ;-)</div>
<div><br></div><div>*If* we do go with a macro-based approach, I think we can all agree there should be one centralized macro that does this and it should be used *everywhere* that vtkSmartPointer::New is presently used.</div>
<div><br></div><div><br></div><div>David C.</div><div><br></div></div>