It is possible to abuse function interception, and a parallel can be found in the abuse of exception handling. For example, it is possible
to implement looping using the try/throw/catch
mechanism, and Example Sixty-Five illustrates this (which is JavaScript,
but with appropriate changes could equally be C++/Java/C# etc).
Here the function Iterate does something of interest, and then increments a variable called
Count, before testing its value.
If Count is less than a given limit it returns to MyFunc,
whereupon it is called again. If, however, the value of Count reaches the
limit then an exception is thrown, which breaks the execution thread out of the loop, thus allowing it to proceed from there.
This is out-and-out abuse of the exception-handling mechanism for the following reasons:
First, for a counting variable to reach a particular limit is not an 'exceptional' condition — a
try/throw/catch construct
is therefore inappropriate here, and can only confuse developers who expect to see it used in an entirely different context.
Secondly, the try/throw/catch mechanism
incurs a run-time overhead that is disproportionate to the least-possible-cost of the simple iteration
that it is being used to implement.
Finally, it incurs a large code overhead, thus swelling the total code-volume. This increases compile times (in a compiled language),
and increases download and run times in contexts such as client-side JavaScript.