Re: How to turn this C++ into D?

2014-11-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/5/14 2:05 PM, Patrick Jeeves wrote: On Wednesday, 5 November 2014 at 18:56:08 UTC, luminousone wrote: unless delete is explicitly called, I don't believe the destructor would ever be called, it would still have a reference in the static foo_list object that would stop it from being collect

Re: How to turn this C++ into D?

2014-11-06 Thread thedeemon via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 17:45:00 UTC, luminousone wrote: abstract class foo { static DList!foo foo_list; ~this(){ foo_list.remove(this); } One note: when your program exits the runtime does a final GC cycle and collects those things calling destructors/finalizers, however the

Re: How to turn this C++ into D?

2014-11-05 Thread luminousone via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 20:31:54 UTC, Patrick Jeeves wrote: On Wednesday, 5 November 2014 at 19:44:57 UTC, luminousone wrote: On Wednesday, 5 November 2014 at 19:05:32 UTC, Patrick Jeeves wrote: On Wednesday, 5 November 2014 at 18:56:08 UTC, luminousone wrote: unless delete is explicit

Re: How to turn this C++ into D?

2014-11-05 Thread Patrick Jeeves via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 19:44:57 UTC, luminousone wrote: On Wednesday, 5 November 2014 at 19:05:32 UTC, Patrick Jeeves wrote: On Wednesday, 5 November 2014 at 18:56:08 UTC, luminousone wrote: unless delete is explicitly called, I don't believe the destructor would ever be called, it wo

Re: How to turn this C++ into D?

2014-11-05 Thread luminousone via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 19:05:32 UTC, Patrick Jeeves wrote: On Wednesday, 5 November 2014 at 18:56:08 UTC, luminousone wrote: unless delete is explicitly called, I don't believe the destructor would ever be called, it would still have a reference in the static foo_list object that woul

Re: How to turn this C++ into D?

2014-11-05 Thread Patrick Jeeves via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 18:56:08 UTC, luminousone wrote: unless delete is explicitly called, I don't believe the destructor would ever be called, it would still have a reference in the static foo_list object that would stop it from being collected by the gc. This is exactly why I ask

Re: How to turn this C++ into D?

2014-11-05 Thread luminousone via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 18:18:18 UTC, Ali Çehreli wrote: On 11/05/2014 10:12 AM, Adam D. Ruppe wrote: > On Wednesday, 5 November 2014 at 18:10:38 UTC, Ali Çehreli wrote: >> If so, then that push_back would be adding an incomplete object to the >> list. > > scope(success)? I really like

Re: How to turn this C++ into D?

2014-11-05 Thread Ali Çehreli via Digitalmars-d-learn
On 11/05/2014 10:12 AM, Adam D. Ruppe wrote: > On Wednesday, 5 November 2014 at 18:10:38 UTC, Ali Çehreli wrote: >> If so, then that push_back would be adding an incomplete object to the >> list. > > scope(success)? I really like that! :) But still not for this case because in addition to the p

Re: How to turn this C++ into D?

2014-11-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 18:10:38 UTC, Ali Çehreli wrote: If so, then that push_back would be adding an incomplete object to the list. scope(success)? But the D translation worries me too because the destructor won't run at the same time as the C++ version, unless you make it a scop

Re: How to turn this C++ into D?

2014-11-05 Thread Ali Çehreli via Digitalmars-d-learn
On 11/05/2014 10:07 AM, Ali Çehreli wrote: > On 11/05/2014 09:17 AM, Patrick Jeeves wrote: > > > class foo > > { > > static std::list foo_list; > > typedef std::list::iterator iterator; > > public: > > foo() > > { > > foo_list.push_back(this); > > } Argh! I forgot

Re: How to turn this C++ into D?

2014-11-05 Thread Ali Çehreli via Digitalmars-d-learn
On 11/05/2014 09:17 AM, Patrick Jeeves wrote: > class foo > { > static std::list foo_list; > typedef std::list::iterator iterator; > public: > foo() > { > foo_list.push_back(this); > } > ~foo() > { > foo_list.remove(this); > } Going completely off-to

Re: How to turn this C++ into D?

2014-11-05 Thread luminousone via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 17:17:11 UTC, Patrick Jeeves wrote: So this is more a stackoverflow question, but I feel like later searchers will be more likely to find it if I put it here. if I have the following C++ code: class foo { static std::list foo_list; typedef std::list::iterator i

How to turn this C++ into D?

2014-11-05 Thread Patrick Jeeves via Digitalmars-d-learn
So this is more a stackoverflow question, but I feel like later searchers will be more likely to find it if I put it here. if I have the following C++ code: class foo { static std::list foo_list; typedef std::list::iterator iterator; public: foo() { foo_list.push_back(this);