Version declaration proposal

Nick Sabalausky a at a.a
Wed Feb 11 13:58:38 PST 2009


"Don" <nospam at nospam.com> wrote in message 
news:gmvg64$1v99$1 at digitalmars.com...
> Steve Schveighoffer wrote:
>> On Wed, 11 Feb 2009 09:01:29 +0100, Don wrote:
>>
>>> I think I have a solution to the versioning problems. My belief is that
>>> version statements are fine, and Walter's 'rats nest' argument is valid.
>>> Instead, I believe that version declarations limited to "version = XXX;"
>>> are too weak. They also have syntax which is subtly different to the
>>> rest of the language. (version = A; version = B; looks as though you're
>>> changing the value of the 'version' variable).
>>> My proposal is therefore:
>>>
>>> --------
>>> * Keep version statements unchanged.
>>> * Change version declarations to make them almost identical to bool
>>> declarations:
>>>
>>> version _versionidentifier_ = _versionexpression_;
>>>
>>
>>
>> I like this idea.  I had one similar last night, but you beat me to it ;)
>>
>> My idea was going to be something that is similar to the current version 
>> statements:
>>
>> version = _expression_ ? _identifier_ [ : _elseidentifier_ ]
>>
>> Where the [...] is optional.
>>
>> But your way looks cleaner.
>>
>> Not in love with the version x = extern notation ...
>
> Me neither. Of the two options I presented, I've decided I prefer
> extern version x;

But there should be a way to specify a default value. I propose this:

// FeatureX *must* be specified on cmd line.
extern version FeatureX;
version(FeatureX)... // Ok

// FeatureX *can* be specified on cmd line, default is true.
extern version FeatureX = true;
version(FeatureX)... // Ok

// FeatureX is true and *cannot* be specified on cmd line
version FeatureX = true;
version(FeatureX)... // Ok

// Same as above. FeatureX is true and *cannot* be specified on cmd line.
version FeatureX;
version(FeatureX)... // Ok

// Boolean expressions with other versions are Ok
version FeatureX = (FeatureA || !FeatureB) && Windows;
version(FeatureX)... // Ok

// FeatureX *can* be specified on cmd line, default is complex.
extern version FeatureX = (FeatureA || !FeatureB) && Windows;
version(FeatureX)... // Ok

// Illegal, FeatureX hasn't been declared
version(FeatureX)...

// Ok, Windows is a built-in version declared by the language or compiler.
// Note that on non-Windows platforms,
// the "Windows" version would still exist,
// but it would just be set to false.
version(Windows)...

// Illegal, redefinition of FeatureX
version FeatureX = false; // Ok so far...
version FeatureX = true; // Illegal redefinition
version FeatureX = false; // Also Illegal: same original value, but still a 
redefinition

// Not sure about this
version(FeatureX)...
version FeatureX;





More information about the Digitalmars-d mailing list