Re: exceptions in destructors
* Pete Becker:
Alf P. Steinbach wrote:
* Pete Becker:
Ron wrote:
On Aug 15, 8:12 am, Brendan <catph...@catphive.net> wrote:
Foo foo();
This doesn't create an object. It declares a function called foo
that returns a Foo.
Try it again with:
Foo foo;
Same result, right?
What I actually said, before the misleading snippage, was:
Same result, right? Good catch, though. <g>
I apologize for quoting only the question and not the praise of Ron and the
following emoticon.
In my defense, I didn't realize that snipping the praise and following emoticon,
could be misleading.
Also in my defense, but this may reflect badly on me, I still fail to see any
misleading impression that snipping the praise and emoticon could give (in
particular since that, as I understand it, wasn't relevant to my article)?
I wasn't looking for an explanation of why it was the same. Especially
not this one:
Yes.
The original example was ...
struct Foo {
~Foo() {
try {
throw exception();
} catch (exception e) {
}
}
};
... and as you can see neither the Foo constructor nor its destructor
has any side-effect.
This is quite misleading, since side effects (other than exiting or
throwing exceptions), even if they were present, wouldn't affect the
exception handling in the original example.
The explanation I gave, quoted in full above, about why defining an automatic
Foo object (instead of declaring a routine) doesn't affect the observable
behavior, is both correct and complete, and not at all misleading.
Excluding from consideration, from the meaning of "side-effect", those that can
affect the program's behavior, one must however conclude, as you do, that the
remaining possible side-effects can't affect the program's behavior.
To the degree that the wording in the paragraph quoted above makes that absurd
assumption seem less than completely absurd, *it* is misleading; sorry.
Cheers & hth.,
- Alf
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]