Why version() ?

Chris Nicholson-Sauls ibisbasenji at gmail.com
Wed Feb 11 16:18:21 PST 2009


Jarrett Billingsley wrote:
> On Wed, Feb 11, 2009 at 4:11 PM, Bill Baxter <wbaxter at gmail.com> wrote:
>> I thought he meant this:
>>
>> // once at the top
>> version(SomeFeatureDisabled) {
>> } else { version = SomeFeature; }
>>
>> // in rest of code ...
>> version (SomeFeature)
>> {
>>    codeForFeature();
>> }
> 
> I don't know whether or not Walter _was_ actually insinuating that but
> it's a pretty good idea ;)  the only disadvantage of course being that
> I have to copy the //once at the top part into every file that wants
> to use the SomeFeature version, though that probably
> wouldn't/shouldn't be a big issue in practice.

I had the same thought at first when reading the 'version declarations' 
proposal elsewhere in this thread, and was going to put forth having to 
write 'version Tango = extern;' at the top of modules as an example of 
what could be bad about it... but then it occurred to me how often I've 
ever had to use version(Tango) in the first place.  (Not very often at all.)

It would be the sort of thing you use just here and there, and is 
actually self-documenting in the process, as it makes it clear that 
/this/ module is going to fork on certain versions.  Despite 
reservations, its all growing on me.

-- Chris Nicholson-Sauls



More information about the Digitalmars-d mailing list