[vtk-developers] Smart pointer declaration macro?

Wes Turner wes.turner at kitware.com
Thu Jan 28 10:00:44 EST 2010


On Thu, Jan 28, 2010 at 9:47 AM, David Doria
<daviddoria+vtk at gmail.com<daviddoria%2Bvtk at gmail.com>
> wrote:

> On Thu, Jan 28, 2010 at 9:30 AM, Will Schroeder
> <will.schroeder at kitware.com> wrote:
> > Wes makes a good point. The other thing that is bothering me about
> >
> > vtkSmartPointer<vtkClass> myLocal(true);
> >
> > is that the form of this line of code, if you are not paying attention,
> > suggests that the class is being instantiated off of the stack rather
> than
> > heap. In general stack allocation is not allowed in VTK and I don't want
> > newbies getting the wrong idea.
>
> I agree with Jeff that one of the main ideas here is to stop the
> horrid VTK_CREATE macros that show up because of peoples unwillingness
> to write a 2 line variable declaration throughout their code.
> Standardizing this will prevent the macros as well as make code more
> readable.
>
> I guess it depends on who you want to cater to. Wes, I imagine you
> don't mind the 2 line signatures because you're very accustomed to
> them. However, every time I show someone new to VTK some code, their
> first response is "geez it takes all that just to make a variable!?".
> I'd say it could be scaring off new users. I'd imagine most users are
> c++ beginners, using VTK as a tool for their trade rather than caring
> to be a computer scientist. Actually - are there any statistics on
> this? Have there ever been surveys about who is using VTK?
>
> Hey Dave,

I think you have it backwards.  Macros and shortcuts are great for people
who already know the code.  There may be a moment of "sticker shock" when
you introduce a new person to VTK, but the explicit declarations, long
member function names, and many other idiosyncrasies help to minimize the
amount of *a priori* knowledge a user needs and the number of files that
need to be traversed to find an answer.

The long lines, while intimidating at first, are a new user's best friend a
few days down the line.

- Wes


> Thanks,
>
> David
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtk-developers
>
>


-- 
Wesley D. Turner, Ph.D.
Kitware, Inc.
Technical Leader
28 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4920
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20100128/7807124c/attachment.html>


More information about the vtk-developers mailing list