Re: Bug, feature or just accidental?
On 8/2/2011 8:40 AM, boltar2003@boltar.world wrote:
On Tue, 02 Aug 2011 08:08:58 -0400
Victor Bazarov<v.bazarov@comcast.invalid> wrote:
Why not? Plenty of languages allow multiple return values from a function.
C++ doesn't because its based on C, but thats no reason why a C++ specific
feature such as exceptions couldn't support it.
Right, but letting throw accept multiple objects would present an
inconsistency with the 'return', whereas now it's consistent and
Why does it have to be consistent with return? A function return and an
exception handler are 2 logically different things. If consistency is the
name of the game why do try and catch both require curly brackets around
a block even if there's only a single expression in the block? Looping
constructs don't, "if" doesn't.
logical. Besides, what's the point of throwing multiple objects? Can
there occur several exceptional situations at once? Seems that the most
Perhaps you have a database error and wish to through the error number along
with the table and column names. There are a million other examples.
What you throw is an exception *object*. You shouldn't need to *throw*
an error number or the table and column *names*. Those should be the
data you stuff in your database exception object.
severe is always what you want to report [by throwing]. And, just like
with returning from a function, you're free to wrap your multiple
objects in a struct and throw that.
Sure, but why should you have to? Its an inefficient extra step that could be
eliminated if the language had been designed differently.
You have to because such is the design of the language. If you don't
want to have to, use the language where it's designed the way you want
it to be designed. Or design your own. I am sure whatever you can come
up with will have no shortcomings whatsoever.
V
--
I do not respond to top-posted replies, please don't ask