Improving version(...)
Simen kjaeraas
simen.kjaras at gmail.com
Mon Oct 18 12:56:26 PDT 2010
Don <nospam at nospam.com> wrote:
> My opinion (a significant departure from the current situation,
> unfortunately):
> It should be possible to define version identifiers with booleans.
>
> version EnableFeatureX = !Lite && !Demo;
This looks nice to me, except that the rhs looks like normal code. It
gives me the feeling that version foo = sqrt(bar) should work.
Perhaps version foo = version( bar && !baz ); is better. I'm not sure.
> Possibly:
> * make it illegal to define a version identifier from inside a version
> {} block.
This would break existing code, and it feels logical to write code like
this:
version( foo ) {
// quite a few lines of dependent code
version = bar;
}
Of course, the result is cleaner:
version( foo ) {
// quite a few lines of dependent code
}
version bar = foo;
So I'm a bit torn. Wait, getting a brain wave again....
Ahh. Make that a ++votes.
> * disallow duplicate version definitions.
Absolutely.
> * require declarations for all version identifiers. Versions which are
> set from the command line should be explicitly declared, eg:
> version Lite = extern;
> version Demo = extern;
>
> That would make creating a bird's nest impossible.
> And currently, you can make a typo like:
> version(Linix) {}
> and it compiles happily. I don't like that. Especially when we have
> builtin names like D_Inline_Asm_X86_64!
This is an awesome idea. ++votes
--
Simen
More information about the Digitalmars-d
mailing list