--- Comment #4 from 2010-10-22 05:12:09 PDT ---
(In reply to comment #2)
> I don't see how a class may replace an union.

Variant/Algebraic has to store its data somewhere. Currently it uses some
horrible hack to store it inline of the struct. All problems would be solved
immediately by allocating a VariantStorage object on the heap instead to store
the data.

D2 already relies that much on heap allocation that this shouldn't be a
problem. Think of hidden memory allocation of closures, or consider bug 4397.

On the other hand, adding an onScan hook to the current GC would probably be a
big deal. Just think about recursive data structures: you have to honor nested
structs, static arrays, dynamic arrays. How would this be efficiently

On the other hand, one could just agree to always store a TypeInfo which each
memory block, and let the compiler generate an optional noScan method.
Depending on the implementation details, this could be reasonably efficient,
but would take its toll on the common case; see discussion in issue 3463.

Anyway, this is probably a non-issue, because nobody would seriously consider
to use "Algebraic" for the same purpose as algebraic types usually are used in
functional programming languages. For that it just sucks too much. It would be
different if D would actually support such data types natively.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to