Type unions in D

Fawzi Mohamed fmohamed at mac.com
Wed Sep 16 03:41:06 PDT 2009


On 2009-09-16 02:40:02 +0200, Justin Johansson <procode at adam-dott-com.au> said:

> Jeremie Pelletier Wrote:
> 
>> Justin Johansson Wrote:
>> 
>>> What's the best way of emulating a system of quantified type unions in D  (D1)?
> 
>> What you want sounds a lot like a variant type. Check std.variant in 
>> phobos, it has a template to let you define custom variants through 
>> type tuples.
> 
> Thanks Jeremie.  It certainly does .. but the reason I haven't seen it 
> before is because I'm using D1.  Sure enough though I poked the D2 
> Phobos code and there it was.  Right at the top of the file is the link 
> to Andrei's circa 2002 article in DDJ which makes for very interesting 
> reading.
> 
> http://erdani.org/publications/cuj-04-2002.html
> 
> 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.




More information about the Digitalmars-d mailing list