Re: class destructors must be @disabled?

2022-05-19 Thread bauss via Digitalmars-d-learn
On Wednesday, 18 May 2022 at 19:58:09 UTC, Ali Çehreli wrote: Hmm. Perhaps the guideline should be "all destructors must be @nogc". Ali It should probably just default to that and with no exception, since you will never end up in a situation where you don't want @nogc for a destructor.

Re: class destructors must be @disabled?

2022-05-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/18/22 3:58 PM, Ali Çehreli wrote: Hmm. Perhaps the guideline should be "all destructors must be @nogc". That one I agree with. -Steve

Re: class destructors must be @disabled?

2022-05-18 Thread Ali Çehreli via Digitalmars-d-learn
On 5/18/22 12:45, Steven Schveighoffer wrote: > Not cleaning it up because you're afraid of destructors is not the answer. Fine. The GC allocation issue remains. It looks like one of the following should be observed: a) @disable ~this() for all classes so that we are safe from the

Re: class destructors must be @disabled?

2022-05-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/18/22 2:58 PM, H. S. Teoh wrote: On Wed, May 18, 2022 at 02:35:00PM -0400, Steven Schveighoffer via Digitalmars-d-learn wrote: [...] No. Class destructors are for cleaning up non-GC resources. As long as you stick to those, you can safely run them. Structs that get put into classes have

Re: class destructors must be @disabled?

2022-05-18 Thread Ali Çehreli via Digitalmars-d-learn
On 5/18/22 11:35, Steven Schveighoffer wrote: > Structs that get put into classes have to run their destructors > properly, otherwise, you will have horrible inconsistencies. Does that suggest a different guideline: "Careful with structs in classes." That goes against orthogonality

Re: class destructors must be @disabled?

2022-05-18 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, May 18, 2022 at 02:35:00PM -0400, Steven Schveighoffer via Digitalmars-d-learn wrote: [...] > No. Class destructors are for cleaning up non-GC resources. As long as > you stick to those, you can safely run them. > > Structs that get put into classes have to run their destructors >

Re: class destructors must be @disabled?

2022-05-18 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, May 18, 2022 at 11:02:01AM -0700, Ali Çehreli via Digitalmars-d-learn wrote: [...] > HORROR: > > Now, a big one that I've just realized. > > - The two guidelines above (the "don't touch class members" one and > the "don't allocate" one) miss an important fact that they apply >

Re: class destructors must be @disabled?

2022-05-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/18/22 2:02 PM, Ali Çehreli wrote: Of course, we still should and do have the power to shape our programs any way we want but I think '@disable ~this();' should be added to classes as a general rule unless the programmer knows it will work otherwise. What do you think? No. Class