On Saturday, 21 November 2015 14:40:44 UTC+2, gwowen wrote:
> Öö Tiib <
oot...@hot.ee> writes:
>
> [snip weapons-grade assholery]
You are pointlessly vulgar there.
>
> > What can be a reason to construct a pointless empty object, throw it
> > out of loop to catch and to ignore and discard?
>
> To express clearly the intent -- "Jump from here to the matching catch"
How can doing those odd things express that intent more clearly than
the jump itself?
>
> > Is it really better way to jump out of loop than 'break' or 'goto'?
>
> Its better than break, because break doesn't work over multiple leves.
You are correct that 'break' does not work there but the actual issue
may be the deeply nested loops themselves.
> It's not better than goto, (which is why I said that I prefer the goto).
> But some people simply won't / aren't allowed to use gotos. Usually
> people who prefer hard-and-fast rules to thought.
I do not care about those people, they are robots and can not be good
engineers. Rules like "avoid goto" but "do whatever with exceptions"
feel rather contradicting and not from this world even for such robots.
Here is link to isocpp FAQ for your robot:
https://isocpp.org/wiki/faq/exceptions#why-not-exceptions
Particular quote:
"In particular, do not use exceptions for control flow. throw is not
simply an alternative way of returning a value from a function (similar
to return). Doing so will be slow and will confuse most C++ programmers
who are rightly used to seeing exceptions used only for error
handling. Similarly, throw is not a good way of getting out of a
loop."
>
> Except where performance is critical, clarity should trump performance.
> So unless the throw/catch time dominates the search time (which it
> almost never will) *and* the timing of this section determines the
> program efficiency, its an irrelevance.
That was my first point. Where is your clarity? Lose-lose-lose situation.
Multiple nested loops can't be over large data sets otherwise such nesting
itself is potential performance bottle-neck.