Right now, what's the most important for the success and adoption of D?
Patrick Kreft
patrick_kreft at gmx.net
Sat Sep 29 23:19:33 PDT 2007
Am 29.09.2007, 16:03 Uhr, schrieb Daniel Keep
<daniel.keep.lists at gmail.com>:
>
>
> Patrick Kreft wrote:
>> downs schrieb:
>>> Max Samukha wrote:
>>>> 1. More bugfixes in D 1.0. I would be happy to call it stable some
>>>> day.
>>>> 2. The problem with RAII (destructors are useless:
>>>> http://www.digitalmars.com/d/archives/digitalmars/D/learn/destructors_7525.html
>>>>
>>>> and other threads)
>>>> 3. GUI
>>>
>>> Seconded, especially the first. And the second. Third would be nice
>>> too :)
>>> --downs
>>
>> Hmm Second isnt an issue. I think it was misunderstood. Yeah D have GC
>> and RAII, that means that u can explicit call a destructor and this will
>> be executed.
>
> No, it's not misunderstood. It's *because* D uses garbage collection
> that destructors are nearly useless. An example from the thread:
>
> class MyClass
> {
> OtherClass a;
> this() {
> a = new OtherClass;
> }
> ~this() {
> delete a;
> }
> }
>
> This code is very dangerous because by the time ~this is executed, a may
> already have been deleted. It may not have been. You *cannot* tell.
> 'a' will *probably* exist if you explicitly delete the object, or you
> use RAII, but the problem is that as soon as you miss an object, or
> decide to let the GC handle a single instance, the code becomes
> dangerous and you can't rely on it.
>
> This is solved slightly by having forcibly scoped class instances, but
> these instances are themselves incredibly restricted precisely because
> they can't escape their scope; meaning you can't return them out of
> functions.
>
> The problem, in a nutshell, is that because of the GC, a destructor
> cannot safely act on or modify *any* GC-allocated memory, since you
> never know when it's going to be destroyed.
>
> -- Daniel
>
> P.S. Insert general disclaimers about how there are corner cases and
> exceptions to the above, but I'm far to lazy to point them all out.
I know so long exist an instance of MyClass so her resource will exist
too, or the GC is useless cuz he make man class useless.
Or i can not use that:
class MyClass
{
OtherClass a;
this() {
a = new OtherClass;
}
void doit()
{
a.call() // scasm: opps a was deleted from GC Error eh?
}
~this() {
delete a;
}
}
Look an http://www.digitalmars.com/d/garbage.html
the GC use Reference counting that mean so long a is not noll, it will
never delete.
--
Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/mail/
More information about the Digitalmars-d
mailing list