Can I do an or in a version block?

Tyler Jameson Little beatgammit at gmail.com
Wed Mar 7 22:41:28 PST 2012


> Now, you could do
>
> version(x)
>     version = xOrY
> else version(y)
>     version = xOrY
>
> version(xOrY) {}

Huh, clever! I like it!! I hope I don't have to do that very 
often, though...

> Of course, if the issue is linux || FreeBSD, you might want to 
> just consider
> using Posix. Unless you're doing something that is specific to 
> linux and
> FreeBSD but not Posix in general (which I would expect to be 
> unlikely), Posix
> will do the trick just fine.

Yeah, that was just an example. Perhaps a better example would be 
comparing versions of something:

version (LIBV1 || LIBV2) {
     // include some dirty hacks for old versions
} else {
     // do some new fancy stuff for new features
}

I was mostly thinking that there are things that linux and BSD 
share that other BSDs may not. I know that Mac OS X has some 
subtle differences in a few things.

Anyway, I think this answers my question. I can get by with using 
your suggestion for those (hopefully) rare cases where I need 
something more specific.

Thanks!


More information about the Digitalmars-d-learn mailing list