removal of cruft from D
Don
nospam at nospam.com
Wed Nov 25 05:55:14 PST 2009
Don wrote:
> Walter Bright wrote:
>> Bill Baxter wrote:
>>>> version(int) is like a programming language with one variable. It's
>>>> ridiculous.
>>>
>>> One variable, and one operator, >=.
>>>
>>> To be fair, it was clearly intended to refer to the version of the
>>> final user's app, not a library version or platform version or
>>> anything else.
>>>
>>> But to assume that only apps have versions, and that >= is the only
>>> test you'd ever want to perform is, I agree, pretty silly.
>>
>> The way to use it would be:
>>
>> version (2)
>> {
>> version = HasFeatureX;
>> version = HasFeatureY;
>> version = HasFeatureZ;
>> }
>>
>> ...
>>
>> version (HasFeatureY)
>> {
>> ...
>> }
>
> You cannot use version(int) inside libraries. You can only use it for
> the app. But it's fairly common to have multiple library versions.
And the other stupid case is when an API changes in a later version.
Eg, suppose FeatureZ only exists from version 2 to 8.
You end up with:
version(2)
{
version(9)
{
}
else
{
version = HasFeatureZ;
}
}
Which can get very convoluted.
For this reason, it's usually easier to use version=Version2 than version=2.
More information about the Digitalmars-d
mailing list