Martin Z wrote:
I realize that. I just ran into this problem when I misunderstood the
2.0 generic dictionary functionality - I was using the idiom:
string myRes
try
{
myRes = dict[someKey];
}
catch (KeyNotFoundException
{
myRes = "MyDefaultString";
}
in C# - and then found out that it had catastrophicly bad performance.
Once I switched over to the TryGet functionality, it behaved much
better. And yet I found myself wishing that I could have just used
exceptions this way. Exceptions provide a nice mechanism for results
that, while not reall "exceptional", don't conform to the primary
return type.
Of course I'd never subject another human being to a bizarre concept of
"alternate return types" as it is a very BadPractice concept. Plus it
mucks up the debugger with lots of "first chance exception" stuff.
I was just curious if it was feasible for my own deepest darkest
hobbyhorse projects. More as a novelty than as a "good idea".
Hey... give it a try. That's how we learn.
Just be sure to post back here with your discoveries.