Re: Exception handling?
"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message
news:quj426112sig23i7h2jl4i3d34lsbrieha@4ax.com...
Why does it make a difference if it is .NET or C++? The concept is
exactly
the same.
****
Performance. Throwing an exception in .NET involves a lot more effort
because of the need
to manage references.
Right, I thought that might be the case. You're probably right C++ is more
performant than .NET when throwing 'non-exceptional' exceptions; however, my
understanding is it is still frowned on in C++. But I have not used
exceptions much in C++ so don't know for sure.
If I am parsing integers, I might need to parse millions of them; if I am
parsing scripts,
I might need to process less than 10 of them in a given execution. Scale
matters.
That makes sense, thanks for explaining.
Sadlly, it sounds like the mechanism was complete overkill for something
as trivial as
parsing a simple number, and probably didn't extend to parsing other
interesting syntactic
constructs (e..g, part numbers, social security numbers, etc.), so I
question the utility
of something that could not handle millions of integers efficiently. Even
if there were
errors.
Yes, that's why they added TryParse(). But I agree the decision may not
scale to other things. I still err on the side of using return values
instead of throwing exceptions for things like invalid input, though.
-- David