×
The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.
On Wed, Jul 1, 2015 at 3:11 PM, Robert Rogerson <rrogerson@xxxxxxxxxxx> wrote:
I know that checking the divisor before doing the divide operation would
avoid this issue, but I thought this was one of the purposes of the monitor
group.
Besides the performance, it's worth considering the code readability.
A monitor group is particularly attractive if the alternative
(checking beforehand to ensure the error condition(s) can't occur)
makes the main logic of your code much more verbose or much harder to
read.
Also, some would argue that the true intended purpose of monitor
groups is to handle real errors, not just "infrequent but naturally
occurring conditions". That is, you never *expect* ON-ERROR blocks to
be needed at all, but you include them anyway so that your
mission-critical program can cope with the errors (without sweeping
them under the rug!) and soldier on.
In this particular case, I think checking the divisor is very cheap in
terms of execution time, and moderately cheap in terms of code
clutter. Unless the divide-by-zero condition will almost never occur
(and *should* never occur), I think I would go with the explicit test
for zero.
John Y.
As an Amazon Associate we earn from qualifying purchases.