Re: GC has a "barbaric" destroyng model, I think

2015-02-13 Thread Kagamin via Digitalmars-d-learn
Yeah, since @trusted is checked manually, it's sort of a problem, if you don't know, how to check it.

Re: GC has a "barbaric" destroyng model, I think

2015-02-13 Thread Foo via Digitalmars-d-learn
On Friday, 13 February 2015 at 09:28:30 UTC, Kagamin wrote: On Friday, 13 February 2015 at 09:11:26 UTC, Foo wrote: And I wouldn't say indiscriminately. Every function I marked with @trusted was checked by me so far. What did you check them for? :) Just first example: make and destruct, being

Re: GC has a "barbaric" destroyng model, I think

2015-02-13 Thread Kagamin via Digitalmars-d-learn
On Friday, 13 February 2015 at 09:11:26 UTC, Foo wrote: And I wouldn't say indiscriminately. Every function I marked with @trusted was checked by me so far. What did you check them for? :) Just first example: make and destruct, being marked as @trusted, don't prevent caller from UAF and double

Re: GC has a "barbaric" destroyng model, I think

2015-02-13 Thread Foo via Digitalmars-d-learn
On Friday, 13 February 2015 at 08:00:43 UTC, Kagamin wrote: On Thursday, 12 February 2015 at 17:29:34 UTC, Foo wrote: And since today it is @safe wherever possible. Well, you marked functions @trusted rather indiscriminately :) Such approach doesn't really improve safety, and the code could w

Re: GC has a "barbaric" destroyng model, I think

2015-02-13 Thread Kagamin via Digitalmars-d-learn
On Thursday, 12 February 2015 at 17:29:34 UTC, Foo wrote: And since today it is @safe wherever possible. Well, you marked functions @trusted rather indiscriminately :) Such approach doesn't really improve safety, and the code could work as well being @system. It's not like @system is inherentl

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread Foo via Digitalmars-d-learn
On Thursday, 12 February 2015 at 14:44:07 UTC, Kagamin wrote: On Thursday, 12 February 2015 at 12:52:03 UTC, Andrey Derzhavin wrote: If we can't relay on GC wholly, there is no need for GC. All of the objects, that I can create, I can destroy manually by myself, without any doubtful GC destroyi

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread Kagamin via Digitalmars-d-learn
On Thursday, 12 February 2015 at 11:10:35 UTC, ponce wrote: On Thursday, 12 February 2015 at 09:50:39 UTC, ketmar wrote: On Thu, 12 Feb 2015 09:04:27 +, ponce wrote: http://p0nce.github.io/d-idioms/#The-trouble-with-class-destructors I've also made one for "D can't do real-time because it

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread Kagamin via Digitalmars-d-learn
On Thursday, 12 February 2015 at 12:52:03 UTC, Andrey Derzhavin wrote: If we can't relay on GC wholly, there is no need for GC. All of the objects, that I can create, I can destroy manually by myself, without any doubtful GC destroying attempts. Manual memory management should be possible in D

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread ketmar via Digitalmars-d-learn
On Thu, 12 Feb 2015 13:55:20 +, Andrey Derzhavin wrote: > On Thursday, 12 February 2015 at 13:11:48 UTC, ketmar wrote: >> sure. but when it comes, for example, for big data structures with >> complex cross-references, you'll inevitably found that you either >> leaking memory, or writing your o

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread ketmar via Digitalmars-d-learn
On Thu, 12 Feb 2015 13:21:07 +, Paulo Pinto wrote: > On Thursday, 12 February 2015 at 09:41:50 UTC, ketmar wrote: >> On Thu, 12 Feb 2015 09:26:12 +, Kagamin wrote: >> >>> That's a repetition of C++ atavism, that resource management == memory >>> management. IStream is a traditional exampl

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread Andrey Derzhavin via Digitalmars-d-learn
On Thursday, 12 February 2015 at 13:11:48 UTC, ketmar wrote: sure. but when it comes, for example, for big data structures with complex cross-references, you'll inevitably found that you either leaking memory, or writing your own half-backed semi-working GC realization. ah, good luck doing ef

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread Paulo Pinto via Digitalmars-d-learn
On Thursday, 12 February 2015 at 09:41:50 UTC, ketmar wrote: On Thu, 12 Feb 2015 09:26:12 +, Kagamin wrote: That's a repetition of C++ atavism, that resource management == memory management. IStream is a traditional example of a GC-managed object, which needs deterministic destruction, and

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread ketmar via Digitalmars-d-learn
On Thu, 12 Feb 2015 12:52:02 +, Andrey Derzhavin wrote: > If we can't relay on GC wholly, there is no need for GC. > All of the objects, that I can create, I can destroy manually by myself, > without any doubtful GC destroying attempts. sure. but when it comes, for example, for big data struc

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread Andrey Derzhavin via Digitalmars-d-learn
On Thursday, 12 February 2015 at 12:29:47 UTC, Marc Schütz wrote: Exactly. That's why it's wrong to rely on the GC if you need deterministic resource management. It's simply the wrong tool for that. Unfortunately, the "right" tools are a bit awkward to use, for the time being. I still have h

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread ketmar via Digitalmars-d-learn
On Thu, 12 Feb 2015 12:10:21 +, Andrey Derzhavin wrote: > if GC does not guarantee the calling of dtor we can't be sure that some > textures will be destroyed. > It will be followed by overflowing of the video memory. > And it is obvious, becouse we have no way to detect when the objects are >

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread via Digitalmars-d-learn
On Thursday, 12 February 2015 at 12:10:22 UTC, Andrey Derzhavin wrote: OK. there is some example: // we're using an OpenGL class A { protected int m_tex; this() { // texture has been created in video memory. there is no GC resource. glGenTexture(1, &m_

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread via Digitalmars-d-learn
On Thursday, 12 February 2015 at 11:11:53 UTC, ponce wrote: On Thursday, 12 February 2015 at 10:24:38 UTC, Mike Parker wrote: On 2/12/2015 6:09 PM, weaselcat wrote: On Thursday, 12 February 2015 at 08:33:35 UTC, Kagamin wrote: Truth be told, D has no guideline for deterministic destruction of

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread Andrey Derzhavin via Digitalmars-d-learn
OK. there is some example: // we're using an OpenGL class A { protected int m_tex; this() { // texture has been created in video memory. there is no GC resource. glGenTexture(1, &m_tex); glTexImage2D(); // texture in video memory

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread ketmar via Digitalmars-d-learn
On Thu, 12 Feb 2015 11:10:34 +, ponce wrote: > On Thursday, 12 February 2015 at 09:50:39 UTC, ketmar wrote: >> On Thu, 12 Feb 2015 09:04:27 +, ponce wrote: >> >>> http://p0nce.github.io/d-idioms/#The-trouble-with-class-destructors >>> >>> I've also made one for "D can't do real-time becau

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread ponce via Digitalmars-d-learn
On Thursday, 12 February 2015 at 10:24:38 UTC, Mike Parker wrote: On 2/12/2015 6:09 PM, weaselcat wrote: On Thursday, 12 February 2015 at 08:33:35 UTC, Kagamin wrote: Truth be told, D has no guideline for deterministic destruction of managed resources. +1 don't complain about people wonderi

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread ponce via Digitalmars-d-learn
On Thursday, 12 February 2015 at 09:50:39 UTC, ketmar wrote: On Thu, 12 Feb 2015 09:04:27 +, ponce wrote: http://p0nce.github.io/d-idioms/#The-trouble-with-class-destructors I've also made one for "D can't do real-time because it has a stop-the-world GC" http://p0nce.github.io/d-idioms/#Th

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread Mike Parker via Digitalmars-d-learn
On 2/12/2015 6:09 PM, weaselcat wrote: On Thursday, 12 February 2015 at 08:33:35 UTC, Kagamin wrote: Truth be told, D has no guideline for deterministic destruction of managed resources. +1 don't complain about people wondering why class destructors don't work when there's no _real_ way to do

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread ketmar via Digitalmars-d-learn
On Thu, 12 Feb 2015 09:04:27 +, ponce wrote: > http://p0nce.github.io/d-idioms/#The-trouble-with-class-destructors > > I've also made one for "D can't do real-time because it has a > stop-the-world GC" > http://p0nce.github.io/d-idioms/#The-impossible-real-time-thread > > And one for "D does

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread ketmar via Digitalmars-d-learn
On Thu, 12 Feb 2015 09:26:12 +, Kagamin wrote: > That's a repetition of C++ atavism, that resource management == memory > management. IStream is a traditional example of a GC-managed object, > which needs deterministic destruction, and not because it consumes > memory, but because it encapsula

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread ketmar via Digitalmars-d-learn
On Thu, 12 Feb 2015 09:26:12 +, Kagamin wrote: > That's a repetition of C++ atavism, that resource management == memory > management. IStream is a traditional example of a GC-managed object, > which needs deterministic destruction, and not because it consumes > memory, but because it encapsula

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread Kagamin via Digitalmars-d-learn
On Thursday, 12 February 2015 at 08:55:43 UTC, Jonathan M Davis wrote: On Thursday, February 12, 2015 08:33:34 Kagamin via Digitalmars-d-learn wrote: Truth be told, D has no guideline for deterministic destruction of managed resources. Really what it comes down to is that if you want determini

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread weaselcat via Digitalmars-d-learn
On Thursday, 12 February 2015 at 08:33:35 UTC, Kagamin wrote: Truth be told, D has no guideline for deterministic destruction of managed resources. +1 don't complain about people wondering why class destructors don't work when there's no _real_ way to do it in D beyond 'drop down to C level

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread ponce via Digitalmars-d-learn
On Thursday, 12 February 2015 at 08:14:49 UTC, Mike Parker wrote: On 2/12/2015 6:42 AM, ketmar wrote: this problem has very easy solition: we should stop calling class dtors "destructors", and rename them to "finalizers". Absolutely. So many people coming from C++ see "destructor" and wa

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, February 12, 2015 08:33:34 Kagamin via Digitalmars-d-learn wrote: > Truth be told, D has no guideline for deterministic destruction > of managed resources. Really what it comes down to is that if you want deterministic destruction, you _don't_ use managed resources. You use malloc and

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread Kagamin via Digitalmars-d-learn
Truth be told, D has no guideline for deterministic destruction of managed resources.

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread Mike Parker via Digitalmars-d-learn
On 2/12/2015 6:42 AM, ketmar wrote: this problem has very easy solition: we should stop calling class dtors "destructors", and rename them to "finalizers". Absolutely. So many people coming from C++ see "destructor" and want to use them as they did in C++. How often do we see people coming

Re: GC has a "barbaric" destroyng model, I think

2015-02-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, February 11, 2015 21:40:30 Orvid King via Digitalmars-d-learn wrote: > On Wednesday, 11 February 2015 at 21:34:00 UTC, Andrey Derzhavin > wrote: > >If we are using a DMD realization of destroying of > > objects, happens the following: at the calling the «destroy» > > method t

Re: GC has a "barbaric" destroyng model, I think

2015-02-11 Thread Orvid King via Digitalmars-d-learn
On Wednesday, 11 February 2015 at 21:34:00 UTC, Andrey Derzhavin wrote: If we are using a DMD realization of destroying of objects, happens the following: at the calling the «destroy» method the calling of dtor takes place always, and then the object which is being destroyed is initializ

Re: GC has a "barbaric" destroyng model, I think

2015-02-11 Thread ketmar via Digitalmars-d-learn
On Wed, 11 Feb 2015 21:33:59 +, Andrey Derzhavin wrote: > If we are using a DMD realization of destroying of objects, happens the > following: at the calling the «destroy» method the calling of dtor takes > place always, and then the object which is being destroyed is > initialized by the de

GC has a "barbaric" destroyng model, I think

2015-02-11 Thread Andrey Derzhavin via Digitalmars-d-learn
If we are using a DMD realization of destroying of objects, happens the following: at the calling the «destroy» method the calling of dtor takes place always, and then the object which is being destroyed is initialized by the default state. In other words, after calling «destroy» method,