Type unions in D

Daniel Keep daniel.keep.lists at gmail.com
Thu Sep 17 06:40:37 PDT 2009



language_fan wrote:
> Wed, 16 Sep 2009 12:41:06 +0200, Fawzi Mohamed thusly wrote:
> 
>> On 2009-09-16 02:40:02 +0200, Justin Johansson
>> <procode at adam-dott-com.au> said:
> 
>>> A colleague of mine is suggesting that I really do take a closer look
>>> at D2 now but I'm not sure that I'm ready to go standing on the
>>> bleading bleading (the blood doesn't clot) edge just right yet. :-(
>>>
>>> JJ
>> Tango has variant (tango.core.Variant), and is D1, if that could be an
>> option for you.

Tango and Phobos2's Variants are very different beasts.

Phobos2's Variant is a discriminated union; you give it a set of types,
and that's what it can store.  The general-purpose one, I believe, can
store any type so long as it's no larger than the biggest primitive
types (it can't store big structs or static arrays, for example).

Tango's Variant is a generic boxer.

> Do the various variant structures presented here support recursive type 
> definitions such as lists? Is this done efficiently?

Given the above, this question doesn't apply to Tango at all.



More information about the Digitalmars-d mailing list