GC interpreting integer values as pointers
Steven Schveighoffer
schveiguy at yahoo.com
Thu Oct 14 10:32:56 PDT 2010
On Thu, 14 Oct 2010 12:39:33 -0400, bearophile <bearophileHUGS at lycos.com>
wrote:
> Steven Schveighoffer:
>
>> There are two problems here. First, D has unions, so it is impossible
>> for
>> the GC to determine if a union contains an integer or a pointer.
>
> D has unions, and sometimes normal C-style unions are useful. But in
> many situations when you have a union you also keep a tag that
> represents the type, so in many of those situations you may use the
> tagged union of Phobos, std.variant.Algebraic (if the Phobos
> implementation is good enough, currently unfinished and not good enough
> yet) and the D GC may be aware and read and use the tag of an Algebraic
> union to know at runtime what's the type. This improves the GC precision
> a little.
Unions are rare enough that I think this may not be worth doing. But yes,
it could be had.
-Steve
More information about the Digitalmars-d-learn
mailing list