version()
Jonathan M Davis
jmdavisProg at gmx.com
Mon Jan 16 03:33:07 PST 2012
On Monday, January 16, 2012 11:37:13 Marco Leise wrote:
> I would like to write:
>
> void main() {
> version(!unittest) {
> run_the_program();
> }
> }
>
> This is a case where the trait you check for is so specific that checking
> for the negation has a clear benefit. I agree with your opinion on OS
> versions, which are more like an enum, where you go through it like a
> switch-case.
That's done easily enough:
version(unittest) void main() {}
else void main()
{
//the program
}
As long as you only need to be able to say "this version" and "not this
version" rather than "this version", "that version", and "not some other
version," you're okay, since the else essentially functions as a !. It just
won't do it for more complicated chains of versions.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list