Re: [[gtkmm] Alternate libglademm interface]



joey yandle wrote:

In Java, this code wouldn't compile; the compiler would insist on
foo() either catching or throwing bar_exception.  But in c++, this isn't
the case.  So by putting a throw() clause, we've guarenteed that the app
will abort if presented with an exception not in the throw clause.  I
find this to be extremely bad ;(


It should be quite obvious that this cannot be enforced at compile time without breaking just about every piece of existing code out there. I guess a warning would have been nice in an obvious case like that, but that's rather a GCC problem, isn't it?


I find throw() clauses in c++ to be worse than useless, and do nothing to
improve code quality.


So if that's worse than useless, what's the alternative?

I assume that we agree to the importance of a user of a class to know what exceptions are thrown by a particular method. So where, would you say, is the better place to put it? A comment in the declaration? In the docs? Trust the users sixth sense?

--
Christer Palm




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]