version: multiple conditions

Joakim via Digitalmars-d digitalmars-d at puremagic.com
Sun Jun 28 07:21:52 PDT 2015


On Sunday, 28 June 2015 at 13:43:39 UTC, Artur Skawina wrote:
> On 06/28/15 05:06, Joakim via Digitalmars-d wrote:
>> So you're trying to avoid writing this?
>> 
>> version(linux) version(D_LP32)
>>     version = valistIsCharPointer;
>> else version(Windows)
>>     version = valistIsCharPointer;
>> 
>> While your version is more concise, I actually think the 
>> current form is more clear.
>
> And wrong. Spot the bug.

Eh, that idiom is not commonly used so I wasn't exactly clear on 
the syntax, but you're presumably referring to the need for 
braces?

version(linux)
{   version(D_LP32) version = valistIsCharPointer; }
else version(Windows)
     version = valistIsCharPointer;

I actually find this even more clear, the best of the bunch. :)

> That's the real reason why 'version' needs to be banned from 
> the codebase. You should *never* use D's 'version'.

If you think it needs to be banned because of some non-obvious 
bracing syntax, you don't have much to stand on.


More information about the Digitalmars-d mailing list