Deterministic resource freeing - delete deprecation (again)
Mariusz Gliwiński
alienballance at gmail.com
Wed Apr 27 04:42:22 PDT 2011
Hello,
I'm next person, which isn't necessarily happy about delete operator
deprecation.
Because constructors / destructors are frequently used not only for
application controlled memory management, how would You implement
something like following code without delete operator?
<code>
void main(string[] args) {
auto res = new Resource();
auto s1 = new FirstSystem(res);
delete s1;
auto s2 = new SecondSystem(res);
}
class FirstSystem {
this(Resource res) {
res.referenced = true;
}
~this() {
res.referenced=false;
}
}
class SecondSystem {
this(Resource res) {
assert(!res.referenced);
}
}
</code>
Next questions would be:
* Are you going to drop destructor as well, or maybe destructor is going
to be confusing feature with non-deterministic behaviour? (How would i
know when heap allocated Socket will be destructed -> when connection
will be closed -> if my system gonna be DoS'ed?)
* Are you going to stop supporting object oriented programming? (Well,
if *deterministic* resource managing can be only inside function, and
not object boundaries, that's my conclusion).
And finally, don't get me wrong. I'm just caricaturizing my current
worries about the language, and if I'm missing something - please hint
me what.
Sincerely,
Mariusz Gliwiński
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20110427/e0afbd71/attachment.html>
More information about the Digitalmars-d
mailing list