What is the point of D_Version2

Kirk McDonald kirklin.mcdonald at gmail.com
Sun Sep 2 10:50:19 PDT 2007


0ffh wrote:
> Derek Parnell wrote:
> 
>> This code below doesn't compile in V1 dmd.
>> [...]
>> I can understand why - because the first two alias declarations have
>> invalid V1 syntax - but doesn't that make the whole D_Version2 thing
>> pointless?
> 
> 
> Um, I see it's a pain. Surely you know the string mixin workaround?
> 
> Regards, Frank
> 
> 

For the record, the string mixin workaround looks like this:

version (D_Version2) {
     mixin("alias const(char)* c_str;");
} else {
     alias char* c_str;
}

You can find this code near the top of the Python header.
http://dsource.org/projects/pyd/browser/trunk/infrastructure/python/python.d

So far as I can tell, I was the first person to come up with (or at 
least use) this workaround, but others may have come up with it on their 
own.

-- 
Kirk McDonald
http://kirkmcdonald.blogspot.com
Pyd: Connecting D and Python
http://pyd.dsource.org


More information about the Digitalmars-d-learn mailing list