digitalmars.D.learn - Reference Counted Class
- sclytrack (4/4) Jul 14 2021 Would reference counted classes by default be too much of a
- IGotD- (12/17) Jul 14 2021 Since classes are reference type, I think it can be done. If I'm
- Tejas (9/28) Jul 14 2021 For deterministic object destruction, there's the ```scope```
- jfondren (5/11) Jul 14 2021 One or the other. The `scope(exit)` will still fire on scope exit
- Tejas (3/6) Jul 14 2021 This isn't happening until DIP 1000 passes successfully(which
Would reference counted classes by default be too much of a change? Is it a bad idea? Currently there a changes in the language where you can avoid the reference count, right? Combination both the rc and the stop-the-world gc, for the cycles.
Jul 14 2021
On Wednesday, 14 July 2021 at 17:52:16 UTC, sclytrack wrote:Would reference counted classes by default be too much of a change? Is it a bad idea? Currently there a changes in the language where you can avoid the reference count, right? Combination both the rc and the stop-the-world gc, for the cycles.Since classes are reference type, I think it can be done. If I'm wrong please explain why. Now, I think there might problems with existing code as there is no concern about the RC when classes are passed around. However, for new code this can be mitigated. In practice this would lead to RC classes while other structures would still be garbage collected. This would reduce the amount of garbage collected memory which could be beneficial. What I would find interesting is if this would enable deterministic destruction of classes. It's an interesting subject and could be a half way step to more a more versatile memory management.
Jul 14 2021
On Wednesday, 14 July 2021 at 18:04:59 UTC, IGotD- wrote:On Wednesday, 14 July 2021 at 17:52:16 UTC, sclytrack wrote:For deterministic object destruction, there's the ```scope``` storage class: ```d scope class_instance = new class(); scope(exit) class_instance.destroy ``` Isn't the exact same as real RC, but then you can use automem for C++ style reference counting if you want.Would reference counted classes by default be too much of a change? Is it a bad idea? Currently there a changes in the language where you can avoid the reference count, right? Combination both the rc and the stop-the-world gc, for the cycles.Since classes are reference type, I think it can be done. If I'm wrong please explain why. Now, I think there might problems with existing code as there is no concern about the RC when classes are passed around. However, for new code this can be mitigated. In practice this would lead to RC classes while other structures would still be garbage collected. This would reduce the amount of garbage collected memory which could be beneficial. What I would find interesting is if this would enable deterministic destruction of classes. It's an interesting subject and could be a half way step to more a more versatile memory management.
Jul 14 2021
On Wednesday, 14 July 2021 at 18:33:56 UTC, Tejas wrote:For deterministic object destruction, there's the ```scope``` storage class: ```d scope class_instance = new class(); scope(exit) class_instance.destroy ```One or the other. The `scope(exit)` will still fire on scope exit in the case of `auto class_instance`, and the object will still be destructed on scope exit without any such `scope(exit)` in the case of `scope class_instance`.
Jul 14 2021
On Wednesday, 14 July 2021 at 17:52:16 UTC, sclytrack wrote:Would reference counted classes by default be too much of a change? Is it a bad idea? Currently there a changes in the language where you can avoid the reference count, right?This isn't happening until DIP 1000 passes successfully(which isn't anytime soon, unfortunately).
Jul 14 2021