On Saturday, 15 October 2016 at 16:22:35 UTC, Nordlöw wrote:
Is there a way to check if a pointer is supposed to point to non-GC allocated memory? I presume not. This is needed to prevent unnecessary calls to `GC.addRange` in containers with elements of a type that in turn is a container-like struct with non-GC allocated memory.

If not, maybe we could tag those non-GC-mangaged pointers with a UDA, preferrably `@nogc`, and then build a trait, say, `hasGCIndirections` that doesn't include @nogc-pointers.

What do you think?

I agree. We are several people to do it already. I've started to during last spring (see https://forum.dlang.org/post/ficbsdfokvbvslatm...@forum.dlang.org).
So far I use "@NoGc" and "@TellGcRange" added.

"@NoGc" is like what you describe, but it also allows to annotate class instances and, very important: D builtin array !

"@TellGcRange" prints a diagnostic at compile time which allows to find which aggregate members force my equivalent of "make" (called "construct") to declare a GC range (it should even be a root actually...).

To be honest I find this system way more useful that the function attribute @nogc. My trait is here (https://github.com/BBasile/iz/blob/master/import/iz/memory.d#L145) but it's quite similar to the one used in EMSI containers (with diagnostic added).

Reply via email to