Re: Bug in RefCounted?

2013-10-29 Thread Kenji Hara
On Tuesday, 29 October 2013 at 11:46:53 UTC, Rene Zwanenburg wrote: On Monday, 28 October 2013 at 19:30:12 UTC, Maxim Fomin wrote: Here is my attempt: import std.stdio; struct S { int i; this(int i) { writefln("ctor, %X", i); this.i = i; } this(this) { writefln("postblit, %X, %X", &th

Re: Bug in RefCounted?

2013-10-29 Thread Ali Çehreli
On 10/29/2013 11:11 AM, Maxim Fomin wrote: > On Tuesday, 29 October 2013 at 17:57:01 UTC, Ali Çehreli wrote: >> http://forum.dlang.org/post/l4osr0$2f3q$1...@digitalmars.com > I did this in 2 January > (http://forum.dlang.org/thread/lpljpfjxwobniglwn...@forum.dlang.org) and > received exactly

Re: Bug in RefCounted?

2013-10-29 Thread Maxim Fomin
On Tuesday, 29 October 2013 at 17:57:01 UTC, Ali Çehreli wrote: On 10/29/2013 08:47 AM, Maxim Fomin wrote: On Monday, 28 October 2013 at 20:43:01 UTC, Ali Çehreli wrote: What is the purpose of writeln in that delegate? Obviously, to print 1. Yet it doesn't happen that way. Is this accepted to

Re: Bug in RefCounted?

2013-10-29 Thread Ali Çehreli
On 10/29/2013 08:47 AM, Maxim Fomin wrote: On Monday, 28 October 2013 at 20:43:01 UTC, Ali Çehreli wrote: What is the purpose of writeln in that delegate? Obviously, to print 1. Yet it doesn't happen that way. Is this accepted to be a bug? Should the programmer 'new' the object instead? Ali

Re: Bug in RefCounted?

2013-10-29 Thread Maxim Fomin
On Tuesday, 29 October 2013 at 12:03:09 UTC, Rene Zwanenburg wrote: On Monday, 28 October 2013 at 19:40:26 UTC, Maxim Fomin wrote: The fact that structs are movable and there is too few struct runtime reflection makes them noncollectable. However, you can wrap struct inside class, in such case

Re: Bug in RefCounted?

2013-10-29 Thread Maxim Fomin
On Tuesday, 29 October 2013 at 11:46:53 UTC, Rene Zwanenburg wrote: That's pretty nasty :). But I suspect this is a bug and not by design. __dtor and __traits are, IMHO, the proverbial escape hatch D should provide, so I think that's OK. I take it that by control flow trick you mean the try/c

Re: Bug in RefCounted?

2013-10-29 Thread Maxim Fomin
On Monday, 28 October 2013 at 20:43:01 UTC, Ali Çehreli wrote: What is the purpose of writeln in that delegate? Obviously, to print 1. Yet it doesn't happen that way. Is this accepted to be a bug? Should the programmer 'new' the object instead? Ali In my opinion it is a corner case, a cons

Re: Bug in RefCounted?

2013-10-29 Thread Rene Zwanenburg
On Monday, 28 October 2013 at 19:40:26 UTC, Maxim Fomin wrote: The fact that structs are movable and there is too few struct runtime reflection makes them noncollectable. However, you can wrap struct inside class, in such case struct dtor will be called. Yeah, if wrapping inside a class would

Re: Bug in RefCounted?

2013-10-29 Thread Rene Zwanenburg
On Monday, 28 October 2013 at 19:30:12 UTC, Maxim Fomin wrote: Here is my attempt: import std.stdio; struct S { int i; this(int i) { writefln("ctor, %X", i); this.i = i; } this(this) { writefln("postblit, %X, %X", &this, i); } ~this() { writefln("dtor, %X, %X", &this, i); } }

Re: Bug in RefCounted?

2013-10-28 Thread Ali Çehreli
On 10/28/2013 12:30 PM, Maxim Fomin wrote: > So do you *know* cases or suspect that they may exists? Or remember some > bug issue? > > Here is my attempt: > > import std.stdio; > > struct S > { > int i; > this(int i) { writefln("ctor, %X", i); this.i = i; } > this(this) { writefln(

Re: Bug in RefCounted?

2013-10-28 Thread Maxim Fomin
On Monday, 28 October 2013 at 10:07:15 UTC, Rene Zwanenburg wrote: On Sunday, 27 October 2013 at 23:33:55 UTC, Ali Çehreli wrote: That's news to me. I know that objects may never be destroyed but why multiple times? How many lives do they have? ;) Yeah, I'd like to know this as well. I do reme

Re: Bug in RefCounted?

2013-10-28 Thread Maxim Fomin
On Monday, 28 October 2013 at 16:53:11 UTC, monarch_dodra wrote: On Monday, 28 October 2013 at 10:07:15 UTC, Rene Zwanenburg wrote: Yeah, I'd like to know this as well. I do remember structs allocated on the heap don't have their destructors called at all due to the GC not being precise, I thin

Re: Bug in RefCounted?

2013-10-28 Thread monarch_dodra
On Monday, 28 October 2013 at 10:07:15 UTC, Rene Zwanenburg wrote: Yeah, I'd like to know this as well. I do remember structs allocated on the heap don't have their destructors called at all due to the GC not being precise, I think. But one object allowed to be destructed multiple times? That

Re: Bug in RefCounted?

2013-10-28 Thread Rene Zwanenburg
On Sunday, 27 October 2013 at 23:33:55 UTC, Ali Çehreli wrote: On 10/27/2013 03:04 PM, monarch_dodra wrote: > it *could* be an (older) emplace bug. Do you reproduce with head? I had tested it with head. No, doesn't happen on head. Thanks for testing that. I'm not set up to build dmd or phobos

Re: Bug in RefCounted?

2013-10-27 Thread Ali Çehreli
On 10/27/2013 03:04 PM, monarch_dodra wrote: > it *could* be an (older) emplace bug. Do you reproduce with head? I had tested it with head. No, doesn't happen on head. > Also, keep in mind that DMD *is* allowed to destroy the same > object several times. That's news to me. I know that objects

Re: Bug in RefCounted?

2013-10-27 Thread monarch_dodra
On Sunday, 27 October 2013 at 21:02:01 UTC, Rene Zwanenburg wrote: On Thursday, 24 October 2013 at 16:46:37 UTC, Ali Çehreli wrote: Technically, it is a problem with FooWrapper. Regardless of whether RefCounted's behavior, by default, structs in D are freely copyable and movable value types. Th

Re: Bug in RefCounted?

2013-10-27 Thread Rene Zwanenburg
On Thursday, 24 October 2013 at 16:46:37 UTC, Ali Çehreli wrote: Technically, it is a problem with FooWrapper. Regardless of whether RefCounted's behavior, by default, structs in D are freely copyable and movable value types. The compiler can do those things as it sees fit. Since FooWrapper o

Re: Bug in RefCounted?

2013-10-27 Thread Rene Zwanenburg
On Thursday, 24 October 2013 at 16:40:42 UTC, Jesse Phillips wrote: I answered a question related to RefCount on SO http://stackoverflow.com/questions/4632355/making-a-reference-counted-object-in-d-using-refcountedt/4635050#4635050 Not written to your specific problem, but may give you the info

Re: Bug in RefCounted?

2013-10-24 Thread Ali Çehreli
ed by createFoo(), when the Bar instance goes out of scope. Current behaviour causes an invalid pointer to be passed to destroyFoo(). Is this a bug in RefCounted or am I doing something wrong? Technically, it is a problem with FooWrapper. Regardless of whether RefCounted's behavior, by default, str

Re: Bug in RefCounted?

2013-10-24 Thread Jesse Phillips
y once, on the instance created by createFoo(), when the Bar instance goes out of scope. Current behaviour causes an invalid pointer to be passed to destroyFoo(). Is this a bug in RefCounted or am I doing something wrong? I answered a question related to RefCount on SO http://stackoverflow.com/qu

Bug in RefCounted?

2013-10-24 Thread Rene Zwanenburg
es out of scope. Current behaviour causes an invalid pointer to be passed to destroyFoo(). Is this a bug in RefCounted or am I doing something wrong?