DMD 1.005 release
BCS
BCS at pathlink.com
Wed Feb 7 15:12:28 PST 2007
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.
More information about the Digitalmars-d-announce
mailing list