[vtk-developers] vtkMathTextUtilities and otherPrint test
David Lonie
david.lonie at kitware.com
Tue Jul 10 13:48:05 EDT 2012
On Tue, Jul 10, 2012 at 1:32 PM, David Cole <david.cole at kitware.com> wrote:
> Instead of the goto's, how about something like:
>
> bool err = this->CheckForError();
>
> if (!err)
> {
> mplMathTextLib = PyImport_ImportModule("matplotlib.mathtext");
> err = this->CheckForError(mplMathTextLib);
> }
>
> [snip]
>
> if (err)
> {
> // in case the error was an exception.
> delete this->Parser;
> this->Parser = NULL;
> }
> }
That would work, but I think it loses quite a bit of readability,
especially if applied to something like this (taken from a local patch
I'm working on):
http://codepad.org/E1DVBfhY
That snippet has a somewhat complicated loop and needs to clean up
objects in a couple of places mid-loop and also before returning. It
could be converted to something like above, but I still think gotos
are the best solution here.
Is there an argument against them, other than that they're unusual in
c++? IMO I think they're fine in simple cases like these.
Dave (the other-other dave)
More information about the vtk-developers
mailing list