Re: GC vs Resource management.

2014-05-05 Thread via Digitalmars-d
On Sunday, 4 May 2014 at 16:13:23 UTC, Andrei Alexandrescu wrote: On 5/4/14, 4:42 AM, Marc Schütz schue...@gmx.net wrote: But I'm afraid your suggestion is unsafe: There also needs to be a way to guarantee that no references to the scoped object exist when it is destroyed. Actually, it

Re: GC vs Resource management.

2014-05-05 Thread Dicebot via Digitalmars-d
Very short feedback about original proposal: 1) managing local objects is not really a problem, we already have `scoped` in Phobos for that (and unimplemented scope qualifier as possible more reliable approach) 2) real problem is managing global objects without clear destruction point while

Re: GC vs Resource management.

2014-05-05 Thread Andrei Alexandrescu via Digitalmars-d
On 5/5/14, 3:18 AM, Marc Schütz schue...@gmx.net wrote: On Sunday, 4 May 2014 at 16:13:23 UTC, Andrei Alexandrescu wrote: On 5/4/14, 4:42 AM, Marc Schütz schue...@gmx.net wrote: But I'm afraid your suggestion is unsafe: There also needs to be a way to guarantee that no references to the scoped

Re: GC vs Resource management.

2014-05-04 Thread Jacob Carlborg via Digitalmars-d
On 2014-05-03 14:28, monnoroch wrote: That leaves only to determine, what objects are scoped. Well, that is obviously stack-allocated structs, gc-allocated scope classes and gc-allocated structs in scope classes. Will the destructor of GC allocated scope classes be called when its

Re: GC vs Resource management.

2014-05-04 Thread via Digitalmars-d
On Saturday, 3 May 2014 at 12:28:03 UTC, monnoroch wrote: Back to the dtors: i understand, that all the stuff you propose could make GC faster, simpler, and cooler, Note that this is _not_ the motivation behind the discussed changes. It's primarily about correctness and consistency. What we

Re: GC vs Resource management.

2014-05-04 Thread via Digitalmars-d
On Sunday, 4 May 2014 at 11:42:14 UTC, Marc Schütz wrote: On Saturday, 3 May 2014 at 12:28:03 UTC, monnoroch wrote: Back to the dtors: i understand, that all the stuff you propose could make GC faster, simpler, and cooler, Note that this is _not_ the motivation behind the discussed changes.

Re: GC vs Resource management.

2014-05-04 Thread Andrei Alexandrescu via Digitalmars-d
On 5/4/14, 4:42 AM, Marc Schütz schue...@gmx.net wrote: But I'm afraid your suggestion is unsafe: There also needs to be a way to guarantee that no references to the scoped object exist when it is destroyed. Actually, it should be fine to call the destructor, then blast T.init over the

GC vs Resource management.

2014-05-03 Thread monnoroch via Digitalmars-d
I've been reading all the topics with those radical ideas about the GC and dtors and, honestly, i'd rather call them insane. After all the reading and thinking, i came to conclusion, that what Andrey suggests is to call dtors only on stack-allocated structs. That also implies, that one can't

Re: GC vs Resource management.

2014-05-03 Thread Rikki Cattermole via Digitalmars-d
On Saturday, 3 May 2014 at 12:28:03 UTC, monnoroch wrote: I've been reading all the topics with those radical ideas about the GC and dtors and, honestly, i'd rather call them insane. After all the reading and thinking, i came to conclusion, that what Andrey suggests is to call dtors only on

Re: GC vs Resource management.

2014-05-03 Thread monnoroch via Digitalmars-d
Hey I have this global variable, if I assign a value to it and later null it, it'll call its destructor if its not referenced anywhere else. Which in turn would make me think ref counting would be a good idea. It seems, that ARC is the only way. There were idea to make all non-scoped (in

Re: GC vs Resource management.

2014-05-03 Thread monnoroch via Digitalmars-d
Scoped-objects + ARC on non-scoped objects with dtors + GC on non-scoped objects w/o dtors would arguably solve the problem, especially, is arrays of scoped objects would be considered also scoped, or just add separate scoped arrays.

Re: GC vs Resource management.

2014-05-03 Thread Paulo Pinto via Digitalmars-d
Am 03.05.2014 14:28, schrieb monnoroch: I've been reading all the topics with those radical ideas about the GC and dtors and, honestly, i'd rather call them insane. After all the reading and thinking, i came to conclusion, that what Andrey suggests is to call dtors only on stack-allocated

Re: GC vs Resource management.

2014-05-03 Thread via Digitalmars-d
On Saturday, 3 May 2014 at 13:21:04 UTC, Paulo Pinto wrote: C# and Java also have scoped blocks (using, try-with-resources), similar to Python for resource management. Yeah, but it doesn't work for graphs that maintain resources, such as a scene graph which hold onto texture memory.

Re: GC vs Resource management.

2014-05-03 Thread Paulo Pinto via Digitalmars-d
Am 03.05.2014 16:02, schrieb Ola Fosheim Grøstad ola.fosheim.grostad+dl...@gmail.com: On Saturday, 3 May 2014 at 13:21:04 UTC, Paulo Pinto wrote: C# and Java also have scoped blocks (using, try-with-resources), similar to Python for resource management. Yeah, but it doesn't work for graphs

Re: GC vs Resource management.

2014-05-03 Thread via Digitalmars-d
On Saturday, 3 May 2014 at 14:31:59 UTC, Paulo Pinto wrote: - Make all scene graph nodes IDisposable. - Have a using(rootNode) {} on your render loop That would work for a static scene. But you want to mark resources ready for release when nodes are removed from the graph dynamically. In

Re: GC vs Resource management.

2014-05-03 Thread Paulo Pinto via Digitalmars-d
Am 03.05.2014 16:43, schrieb Ola Fosheim Grøstad ola.fosheim.grostad+dl...@gmail.com: On Saturday, 3 May 2014 at 14:31:59 UTC, Paulo Pinto wrote: - Make all scene graph nodes IDisposable. - Have a using(rootNode) {} on your render loop That would work for a static scene. But you want to

Re: GC vs Resource management.

2014-05-03 Thread via Digitalmars-d
On Saturday, 3 May 2014 at 15:10:43 UTC, Paulo Pinto wrote: Easy, you already know that you don't need the node, just call the dispose method, instead of marking for release. But you don't know unless you use RC or GC. Let's say you make a jungle. Lots of pointers to the tree root node. And

Re: GC vs Resource management.

2014-05-03 Thread Paulo Pinto via Digitalmars-d
Am 03.05.2014 17:20, schrieb Ola Fosheim Grøstad ola.fosheim.grostad+dl...@gmail.com: On Saturday, 3 May 2014 at 15:10:43 UTC, Paulo Pinto wrote: Easy, you already know that you don't need the node, just call the dispose method, instead of marking for release. But you don't know unless you

Re: GC vs Resource management.

2014-05-03 Thread Andrei Alexandrescu via Digitalmars-d
On 5/3/14, 5:39 AM, monnoroch wrote: Hey I have this global variable, if I assign a value to it and later null it, it'll call its destructor if its not referenced anywhere else. Which in turn would make me think ref counting would be a good idea. It seems, that ARC is the only way. There

Re: GC vs Resource management.

2014-05-03 Thread monarch_dodra via Digitalmars-d
On Saturday, 3 May 2014 at 18:27:46 UTC, Andrei Alexandrescu wrote: On 5/3/14, 5:39 AM, monnoroch wrote: Hey I have this global variable, if I assign a value to it and later null it, it'll call its destructor if its not referenced anywhere else. Which in turn would make me think ref counting

Re: GC vs Resource management.

2014-05-03 Thread monnoroch via Digitalmars-d
Interesting, we haven't explored that. The most problematic implication would be that classes with destructors will form a hierarchy separate from Object. As i understood, you want to remove dtors for non-scoped objects completely, so all classes will be without it, except user defined ones.

Re: GC vs Resource management.

2014-05-03 Thread monnoroch via Digitalmars-d
The most problematic implication would be that classes with destructors will form a hierarchy separate from Object. What for? As i understand object's dtor does nothing, so for any class we can determine, if dtor is empty. I don't see a problem here. Cycles and locks for RC are the biggest

Re: GC vs Resource management.

2014-05-03 Thread Michel Fortin via Digitalmars-d
On 2014-05-03 18:27:47 +, Andrei Alexandrescu seewebsiteforem...@erdani.org said: Interesting, we haven't explored that. The most problematic implication would be that classes with destructors will form a hierarchy separate from Object. Seems like people have been ignoring my two posts