On 07/29/2010 04:32 PM, Abdelrazak Younes wrote:
On Thu, Jul 29, 2010 at 5:38 PM, <[email protected] <mailto:[email protected]>> wrote:


    Modified: lyx-devel/trunk/src/mathed/InsetMathXYMatrix.cpp
    
==============================================================================
    --- lyx-devel/trunk/src/mathed/InsetMathXYMatrix.cpp    Thu Jul 29
    17:37:42 2010        (r35024)
    +++ lyx-devel/trunk/src/mathed/InsetMathXYMatrix.cpp    Thu Jul 29
    17:38:01 2010        (r35025)
    @@ -140,4 +140,16 @@
     }


    +void InsetMathXYMatrix::mathmlize(MathStream &) const
    +{
    +       throw MathExportException();
    +}


Why not simply returning a bool?
Exceptions should be reserved to exceptional things that break the working flow. Such is not the case here IMHO.

There seems to be a large philosophical disagreement along these lines. In Python, this would be quite normal. It's less so in C++, but I've been doing a lot of reading about exceptions in C++ lately, and this kind of usage seems to be becoming more common. The problems with returning a bool are (a) that you might want to return something else at some point and (b) that you have to make sure religiously to check for that return value throughout the call stack. One failed check somewhere, and you lose it. Oh, and (c) that there might later be various kinds of failures, and returning an enum is really ugly.

Throwing an exception is so much easier. You just catch it at the point where you care what happened. Of course, you have to make sure to catch it, but you'll find out about a missing catch a lot faster.

Richard

Reply via email to