Re: throwing exception from constructor
- From: "Arnaud Debaene" <adebaene@xxxxxxxxxxxxxxxx>
- Date: Fri, 4 Aug 2006 08:29:20 +0200
"Barry Kelly" <barry.j.kelly@xxxxxxxxx> a écrit dans le message de news:
gf55d25vi26gqbfm8p72mfskjjt6ihbjeg@xxxxxxxxxx
"Arnaud Debaene" <adebaene@xxxxxxxxxxxxxxxx> wrote:
"Barry Kelly" <barry.j.kelly@xxxxxxxxx> a écrit dans le message de news:
acf1d2pj19bjlppmfs4r3qbsmg5termkpg@xxxxxxxxxx
adebaene@xxxxxxxxxxxxxxxx wrote:
In my view, C++'s destructors along with the RAII pattern are basicallyWhich limitation? The limitation is rather on the .NET finalizer side
required to be overused in order to hack around a limitation in the
language.
IMHO :
since you don't know when they are run, there is almost nothing you can
do
inside them!
We'll have to agree to disagree - I think it's a limitation of the
language definition, nothing to do with .NET or otherwise, in the
context of "throwing an exception from the constructor".
But which limitation are you talking about exactly? That's what I don't
understand...
The RAII pattern works very well for simple scenarios (and
they should be used in such reusable scenarios), like an owned pointer
or a ref-counted pointer, but not every paired operation between
constructor and destructor is so reusable that it merits a new type.
That's why there are generic solutions to the RAII idiom, such as
ScopeGuard
(http://www.ddj.com/dept/cpp/184403758)
Yes, more hacks and crutches...
Huuh? Andrei Alexdandrescu doing "hacks and crutchs" ??? Care to justify
your appreciation?
More seriously, I believe there is a true divergence ni philosophy here :
The C++ approach is "do as little as possible in language itself, and as
much as possible in libraries", whereas your approach (I am not really sure
this is indeed the C# approach) is "put everything in language and compiler
itself, so that there is nothing left to do in libraries". I believe the 1st
approach is more flexible because, first, it makes it much easier to replace
a defective component....
Arnaud
MVP - VC
.
- Follow-Ups:
- Re: throwing exception from constructor
- From: Barry Kelly
- Re: throwing exception from constructor
- References:
- throwing exception from constructor
- From: Sek
- Re: throwing exception from constructor
- From: Leon Lambert
- Re: throwing exception from constructor
- From: Barry Kelly
- Re: throwing exception from constructor
- From: Carl Daniel [VC++ MVP]
- Re: throwing exception from constructor
- From: Barry Kelly
- Re: throwing exception from constructor
- From: adebaene
- Re: throwing exception from constructor
- From: Barry Kelly
- Re: throwing exception from constructor
- From: Arnaud Debaene
- Re: throwing exception from constructor
- From: Barry Kelly
- throwing exception from constructor
- Prev by Date: Re: c# - windows form controlbox
- Next by Date: Re: protect passwords in database
- Previous by thread: Re: throwing exception from constructor
- Next by thread: Re: throwing exception from constructor
- Index(es):
Relevant Pages
|