auto classes and finalizers
kris
foo at bar.com
Sun Apr 9 22:21:39 PDT 2006
Regan Heath wrote:
> I have. Here is what you say WRT leaks:
>
>> What about implicit cleanup? In this scenario, it doesn't happen. If
>> you don't explicitly (via delete or via raii) delete an >object, the
>> dtor is not invoked. This applies the notion that it's better to have
>> a leak than a dead program. The leak is a bug >to be resolved.
>
>
> Whereas using my suggestion we get implicit cleanup. Auto propagates as
> required, dtors are added and delete is called automatically where
> required resulting in no leaks. The best part is that the compiler
> enforces that by default and you have to opt-out with 'shared' to
> introduce a leak.
>
> So, assuming it's workable (Walters call) and it's not too inflexible I
> think it's a better solution. In short, I would rather not have to
> explicitly manage the resources if at all possible (and I still hope it
> might be).
I thought the idea was that classes with dtors are /intended/ to be
explicitly cleaned up? That, implicit cleanup of resources (manana, some
time) was actually a negative aspect? At least, that's what Mike was
suggesting, and it seemed like a really good idea.
Along those lines, what I was suggesting is to enable dtors for explicit
cleanup only. Plus an optional runtime leak detector. I guess I like the
simplicity of that. What you suggest seems workable too, but perhaps a
little more involved?
More information about the Digitalmars-d
mailing list