paulto said:
dragan wrote:
[snipped]
Another simple answer from moi: RAII. Problem solved. RAII and
exceptions are orthogonal concepts. RAII works as good with other
error handling strategies as it does with exceptions.
RAII is a great idea but you need something to kick off the
destructors. It may be an important component of error handling
strategy but exception or something else is needed to actually kick off
object
destruction if error processing requires changing the context outside
of normal flow control operation.
Not really. Local objects will have their destructors called when they go
out of scope. That has nothing to do with exceptions, PER SE. Yes, if you
create a C++ exception mechanism, then you must, in turn, create a new way
for destructor calling. Otherwise though, destructors get called when the
object goes out of scope.
Is there a reason why there is so much pedantic and elementary discussion
necessary here? Personally, _I_ assume that everyone here knows everything
in anything ever written in a commonly available C++ book/programming book,
etc. Save for the "harder" stuff. While it is "fun" a little bit to "burn
things in" or "retrive data in the back of the mind", sometimes it appears
that some people in these language groups are just "chomping at the bit" for
an opportunity to recite common knowledge, at the expense of another maybe,
and for what? Is there some contest I don't know about? I felt the need to
"reprimand" and "take to the mat" the other guy for childish tactics for the
very same reason. This little passage is not to curb questions and thoughts
of those who trully don't know and seek to know: there is NO dumb question.
I mean, I remember when I didn't know everything and how it sucked so bad,
but I digress.
(Yes, when I say something that is incorrect, I'm just faking it: I really
do know. Yeah, that's the ticket!)
see below..
see below...
Exactly my point. It won't automatically, you will have to hand-craft
some stupid
Ah, now we are getting "real". You say "stupid" and you meant it
passionately. OK, noted. There's nothing wrong with passion and/or
personality (as if "boring" language newsgroups didn't need help in that
department).
mechanism like EPOC32/Symbian cleanup stack and never
forget put your important objects on it. I am just saying: for error
processing some mechanism of context-switching is needed (BTW
longjmp/setjmp is context-switching: the context in this case are the
registers including instruction pointer or equivalent and stack frame
pointers or equivalents.
I would and do reserve that terminology for the commonly known usage of it:
switching from user mode to kernel mode, and switching threads too.
In practice, it's not enough as you want
application-level "unwinding" of automatic objects as you change the
stack pointers or equivalents;
You don't have to do that if you aren't "setjmping/longjmping" or "C++
exceptioning": it happens just as in normal program flow. Destructors get
called when class objects go out of scope.
that's why I am saying exceptions are
convenient and cheap
You're are juxtaposing "cause and effect".
without obvious drawbacks for the purpose (as
long as you do not require more flexibility in selection of error
processing code targets than exception give you), library-based
cleanup-stack is worse and longjms/setjmp is still worse.. )
OK, this is turning into a tangent about "why you should use exceptions".
Save to say, you are "preaching to the choir". I don't want to age standing
still and this thread is becoming one of those rehashes of stuff everyone
already knows and makes their own choices about. Up next for sure: "why you
should use garbage collection". No offense, but I have better, more
things to do. Unless you have some "new said:
If you terminate the process, the automatic objects are destroyed;
While I don't not believe you, I don't believe you. I probably don't have to
know that either because:
1. It is probably platform-specific.
2. It's not a separate thing to design around the whole envelope of such
behavior.
if
the "task" is something else, you are right, it's on you again
.
That's again why I say exceptions are convenient.
"Convenience" is not even on the list of requirements though.
I mentioned few above; but don't know anything as convenient as
exceptions.
"I gotta go".
I am not trying going there either; but we seem to be talking about
different things when we mention "error" term and this is not
productive.
I didn't see that as hampering the elementary and pendantic dialog, but I do
agree that a reasonably agreed-upon glossary of terms is required for
efficient discussion or debate or problem resolution. I think TOO much time
is spent discussing different things ("talking past each other") in these
language groups for that very reason: everyone starts jabbering in their own
foreign English/Technolang. Which is fine if it is clear from the context,
else it is very wasteful.
I would suggest to exclude A "locably-handleable"
conditions from the discussion.
There is no more discussion unless you have something new (to the larger
scope of the body of knowledge that is this stuff) to present.
I do not see a reason for segregating
them into a separate category of "errors" from other
application-level conditions;
Well you ponder that some more if you want to. I consider classification of
errors an important step in error management. Without thought in that task,
I would assess the development process deficient. Nuff said. I'm not here to
talk about my development methods.
you seem to argue exceptions is not the best way of processing them;
"best" sounds very final. Don't you think? It's a good way. A car may be
"the best way" to go to work, but I still ride my bike sometimes. Go figure!
I
do not challenge this at all, I just do not call these "business
cases" or "uses cases" "errors".
I can't spend more time on this.
See above paragraph this time
.
So, how do you kick-off the destructors for objects you initialized
under RAII paradigm?
"kick off" what? There's nothing to "kick off", unless you are under the
impression that "unwind" is something tied to an exception mechanism. Do you
know what an exception is? Is it different from an "error"? How? Have you
considered that someone like maybe Google who "shuns C++ exceptions" may
not be using ANY other kind of exception either? What is an "exception"? I
believe that answer will answer your questions about "kicking off
destructors".
goto is local withing the function, right?
Yes.
You can call these
situations "locally-handleable errors", too, if you like but they
IMHO do not require macros (no more than other business logic, that is).
By now I'm "getting to know you", and "your take" on macros I'm sure can be
easily ascertained from "your take" on exceptions. No offense, but you are
repeating programming "cliches".
If your
desired control point is few call stacks up, goto can't help you and
this is a distinctive characteristic of an error to me.
So why are you talking at me about it? Thought + time = resolution.
It definitely is if you do not limit the scope of your effort first.
"Fixing the world" is rarely productive enterprise. So, the clear
definition of what is and, most importantly, what is not an error, is
in order as well as some definition of what you would expect from
error management.
"I don't know what an error is". I want you to tell me. Unfortunately, I
have an idea of how long that will take until you know and I can't wait that
long. Don't ever again try to suck me into an elementary/pendantic
discussion about this stuff, thanks. When you have something new to add to
the existing "body of knowledge", I'll probably be reading it.