On Monday, 20 February 2012 at 07:10:39 UTC, Andrei Alexandrescu
wrote:
On 2/20/12 12:44 AM, foobar wrote:
I just died a little reading this. Are you suggesting that in
order
to handle IO exceptions I need to: try { ...whatever... } catch
(PackageException!"std.io") {...} } catch
(PackageException!"tango.io") {...} } catch
(PackageException!"otherLib.io") {...} ...
What the hell is wrong with just using an IOException?
There's nothing wrong, but there's a possible misunderstanding.
If
tango.io and otherLib.io cooperate with std, then they'd
originate
exceptions in std.io (as opposed to their own). Do note that
the issue
is exactly the same if libraries use IOException - they all
must agree
on using the same nomenclature, whether it's called
PackageException!"std.io" or IOException.
The above is patently wrong.
Are you suggesting that tango.io and otherLib.io need to depend
on Phobos IO?? If so, that removes the benefits of using 3rd
party libraries. If that's not your intention (and I really hope
it isn't!) than IOException must be defined in a *separate*
module that tango can depend on.
ModuleException and PackageException have one important thing
going for
them: they automate away a good amount of boilerplate, which
makes them
interesting for me to look at, and worth sharing as long as
we're
brainstorming. The associated issues as clear as the advantages.
Probably ModuleException is too specific to be interesting, but
PackageException seems useful.
Per above, your suggestion actually *adds* boilerplate since you
now want me to use PackageException!"std.io" instead of just
IOException.
AS Nick wrote, it seems you have a complete lack of
understanding of
how exceptions work which is unsurprising coming from a c++
expert.
Always eager to learn (so please come with all you've got), but
quite
honest I hope in a way you're exaggerating, seeing as a lot of
the stuff
I authored for D (the scope statement, exception chaining, a
full
chapter in TDPL) would be completely broken.
"even a broken clock shows the right time twice a day"
Also, this entire discussion you started about "improving"
exceptions
looks to me like a combination of NIH syndrome sparkled with
heavy
doses of premature optimization.
What is being optimized here?
Thanks,
Andrei
It's clear that you are trying to generify exceptions. This
contradicts the very notion of what exceptions are. You also seem
to try to optimize the amount of exception classes. Making user
code convoluted for the sake of some premature optimization which
most likely has negligible affect is completely unacceptable. I
get that you are a templates master, that does *NOT* mean
everything must be made generic.
You seem to prove the old saying that when all you have is a
hammer everything looks like a nail.
[Meta] side-note:
It's extremely irritating when you demand utmost pedantic
reasoning from others while you often answer without providing
such pedantic reasoning yourself or worse answer with a single
word posts. That shows a complete lack of respect for others. You
seem to be of high regard for yourself which is not justified at
all given this attitude.