GC attribute modifications use case?
Steven Schveighoffer
schveiguy at gmail.com
Mon Dec 23 01:04:31 UTC 2024
On Sunday, 22 December 2024 at 04:05:50 UTC, Steven Schveighoffer
wrote:
> So does anyone have any good use cases for setting arbitrary GC
> attributes after allocation?
Rikki pointed out a nice search on github to find all D code that
calls `setAttr`. 90% of the use of `setAttr` is either garbage
(setting the attribute to something that is already set), or
setting `NO_MOVE`, which is currently a no-op (supposedly a
"future" GC might be able to move allocations, but this is
actually impossible in D).
There are some intriguing uses of `setAttr` for `NO_SCAN`, like a
weak-reference object, which sets the attr of `this` in the
constructor. Really, the correct way to do this is to pass in the
right attr on allocation, but D hasn't traditionally made this
very easy to do.
However, I've decided to support the existing unittest for now,
and address this a separate way later.
Will expand on this in the future...
-Steve
More information about the Digitalmars-d
mailing list