why there raii .net?
being essentially c++ developer scarcity java .net always worried me. fact responsibility cleaning adult changed category author the consumer (by means try finally .net's ) seems extremely inferior.
i since java there support raii given objects located store rubbish gourmet inherently doesn't support deterministic destruction, nonetheless .net introduction value-types (struct) have (seemingly) ideal petitioner raii. value form that's combined smoke-stack good tangible range c++ destructor semantics used. however clr does assent value-type have destructor.
my futile searches found justification value-type falls underneath office rubbish gourmet therefore the drop becomes non-deterministic.
i feel justification isn't cunning enough, advantages raii large adequate contend value-type destructor can't boxed (or used category member).
to cut enlarged story brief doubt is: there any reasons value forms used method broach raii .net? (or cruise justification raii's apparent advantages flawed?)
edit: i contingency have phrased doubt clearly given initial 4 answers have missed point. i know finalize the non-deterministic characteristics, i know using make i feel twin options defective raii. using some-more thing consumer category contingency remember (how forgot put streamreader using block?). doubt philosophical libel design, since proceed improved?
for instance general deterministically destructible value-type i using lock keywords over-abundance (achievable library classes):
open struct disposer<t> where t : idisposable
{
t val;
open disposer(t t) { val = t; }
open t value { { relapse val; } }
~disposer() // now illicit
{
(val != default(t))
val.dispose();
}
}
i can't assistance nonetheless finish suitable selection i once saw nonetheless can't now the origin.
you take deterministic drop cold passed palm goes out scope. --anon
Comments
Post a Comment