On Friday, 2 September 2016 at 08:14:33 UTC, Rory McGuire wrote:

Can we rather just make a special tagged union that is scanned... rather avoid trying to make something that should be minimal more and more complex? The compiler already treats some parts of phobos as "special" as far as I know.

I had asked about unions in @safe code in other threads, but I don't recall anyone responding.

@safe functions cannot access unions with pointers or references overlapping with other types. In effect, there is already a special tagged union that can be scanned. I would think that the garbage collector already identifies these types of unions and doesn't just treat every union with the same conservative approach, but I have really no idea how it works and don't recall hearing back about my questions.

Anyway, with @safe unions, my thinking is that it would mean that the garbage collector can be made precise in @safe code in a way that it can't in @system code (assuming unions with pointers aren't snuck in through @trusted).

Reply via email to