DMD 1.005 release

Kyle Furlong kylefurlong at gmail.com
Wed Feb 7 15:27:12 PST 2007


BCS wrote:
> Walter Bright wrote:
>> BCS wrote:
>>
>>>
>>> The point is to have all of the versioning done by the time you link, 
>>> that leaves a runtime check for version info.
>>
>>
>> Not if it's a const.
> 
> if it's a const than it should be a static if.
> 
> static if(globalversion.baz)
>     if(baz) break;
> else
>     break;
> 
> and that still doesn't cover the other case
> 
> switch(i)
> {
>   version(foo)
>     case 1:
> 
>   ...
> 
>   version(!foo)
>     case 1:
> }
> 
> or how about
> 
> outer: while(...)
> {
>  for(...)
>  {
>   ....... // lots of nesting
>         version(Foo)
>          break outer;
>         else
>          continue outer;
>  }
> }
> 
>>> All 32 possibilities??? What if there are 16 independent versions? 
>>> that's 64K functions! And no that is not an unlikely case, say "i" is 
>>> a parse tree and we want to add different types of annotation 
>>> depending on what features are enabled.
>>
>>
>> I'd use bit flags instead of versions for such things. 
> 
> Runtime checks? That would requirer that code to do the processing be 
> compiled in for all cases: Code bloat, etc. And structures would then 
> need to have all the fields for all the features[*] even if they will 
> never be used: Data bloat etc.
> 
> Or are you saying use "static if"? Then what is version for? In that 
> case I can't think of any use AT ALL for version.
> 
> Strike that, versions can be specified on the command line so they could 
> do this:
> 
> module globalversion;
> 
> version(Foo) const bool Foo = true else const bool Foo = false;
> ....
> 
> and then everything is done with static ifs
> 
> *version isn't just for controlling code inclusion.
> 
> struct Part
> {
>     version(Foo) Foo foo;
>     version(Boo) Boo boo;
>     version(Fig) Fig fig;
>     version(Baz) Baz baz;
>     version(Bar) Bar bar;
> }
> 
>> If I had a situation with 32*16 version combinations, I think I'd 
>> seriously consider reengineering what the program considers as a 
>> "version". After all, do you really want to generate 64,000 binaries? 
>> How are you going to test them <g>?
> 
> Most of the cases where I see version used I would expect to have 
> several orders of magnitude more combinations possible than are ever 
> actually built.
> 
> What I would want versioning for would be to be able to arbitrarily 
> select what I want from a set of functionalities. Then by specifying 
> that on the command line, run a build (like with bud or a makefile that 
> doesn't known jack about versions) and get what I want.
> 
> I'm at a loss as to what you envision for versioning.

All this discussion is moot. The feature exists now, use it how you 
like. If you want to use mixin(Config!(import(foo.conf))) to make your 
program n-dimensionally configurable, go ahead. If you agree with 
Walter's view of versioning, don't. I don't see that we need to have 
this discussion at all.

Unless and until Walter restricts the kinds of files import will accept, 
go ahead and use the feature in any way you like.



More information about the Digitalmars-d-announce mailing list