Incremental garbage collection
Ola Fosheim Grøstad
ola.fosheim.grostad at gmail.com
Fri Jan 21 19:02:10 UTC 2022
On Friday, 21 January 2022 at 12:52:02 UTC, Elronnd wrote:
> You do not. You do need to do _something_ about unions, but
> you do need to disallow pointers in them. The spec says to pin
> objects which are in unions, which is a perfectly acceptable
> solution. There are also cleverer solutions which violate that
> clause of the spec but do not break any actual code.
No, pinning is not a solution, that is band-aid for a broken
design. You'll end up with memory leaks all over the place.
Regarding your suggestion, this is not as trivial as you imply.
There is no way today for the type system to know where a pointer
points. So there is also no way to know whether you need to apply
a barrier or not. Since non-D libraries can mutate pointers there
is also no way to be sure that they only modify pointers that
does not require barriers. As a result you risk having spurious
bugs that are impossible to track.
You need some kind of language change to make the type system
work properly with barriers.
More information about the Digitalmars-d