version()

Manu turkeyman at gmail.com
Sun Jan 15 23:25:47 PST 2012


On 16 January 2012 02:37, Jonathan M Davis <jmdavisProg at gmx.com> wrote:

> On Monday, January 16, 2012 02:16:03 Manu wrote:
> > > As for
> > >
> > > version(linux || OSX)
> > >
> > > you can use
> > >
> > > version(Posix)
> > >
> > > It'll include FreeBSD as well, but then again, if something is common
> to
> > > both
> > > linux and OSX, then it's almost certainly in FreeBSD as well.
> >
> > Fair enough, although this is just an example.
> > In my current case, linux and MinGW are the same, but FreeBSD is
> different.
> > You can't rely on predefined unions.
>
> True. I'm just saying that in the case of
>
> version(linux || OSX)
>
> there is a good alternative. Personally, I would have thought that using &&
> and || would be permitted, but it's not. But again, I'd have to dig through
> the archive to see what exactly Walter's arguments were except that he
> definitely thought that allowing && and || would lead to worse code. It
> probably relates to him not wanting to allow !, which I _do_ understand and
> agree with. Something like
>
> version(Posix)
> {}
> else version(Windows)
> {}
> else
>        static assert(0, "Unsupported OS");
>
> will catch bugs and save you trouble in comparison to
>
> version(Posix)
> {}
> else
> {}
>
> Yes, right now. Everything that isn't Posix may be Windows, but that won't
> necessarily always be true. So, when it comes to versioning, code should
> definitely be versioned on what it _is_ rather than what it _isn't_. But
> that
> doesn't preclude having && and ||. It's just an argument for disallowing !.
> And as you can see by my example, you can essentially _already_ do !
> thanks to
> else.


The list of version isn't limited to platforms though, not even close.
There are a bunches of concepts in the list. Including OPTIONAL hardware
features, which probably make he && operator a requirement in addition to
||.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120116/3552d955/attachment.html>


More information about the Digitalmars-d mailing list