version()

Zachary Lund admin at computerquip.com
Sun Jan 15 16:35:21 PST 2012


On 01/15/2012 06:16 PM, Manu wrote:
> On 16 January 2012 02:08, Jonathan M Davis <jmdavisProg at gmx.com
> <mailto:jmdavisProg at gmx.com>> wrote:
>
>     On Monday, January 16, 2012 01:44:56 Manu wrote:
>      > Surely basic logical expressions within a version seem not only
>     logical,
>      > but also very necessary?
>      > There must be a reason this is impossible, or else I can't
>     believe it's not
>      > already like that...
>
>     People have requested it. Walter is against it. I don't remember his
>     exact
>     arguments, but he believes that it leads to worse code if you allow it.
>
>
> Insanity, I argue the exact opposite. My code is WORSE for those 9
> completely useless lines. Any sane person would look at that and wonder
> WTF... especially someone new to the language.
> Imagine my expression was something more complex: version( A || (B && C)
> ) ... the munging code would double in size.
>
>     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.

What exactly are you wanting so I can give an example?

I think the bigger problem is version levels.
For instance there doesn't seem to be a way to "version out" a feature. 
Although there will not be any perfect way. If a feature is at level 7, 
it will not be included with a version level set at 5.

Unfortunately, there is no satisfying both sides. You can do:

version = 5

void main()
{
	int test;
	version(3)
       	{
		/+ Everything in here is now versioned out since version 3 +/
         }
}


or you can have the opposite of which version(3) would have been true 
which would allow for incremental versions but that would mean that 
everything would be wrapped in version statements in the first place. 
Thus I think the code example above makes more sense than what is 
currently in place and everything not wrapped in a version statement is 
assumed to be at the same version level as what is currently set.


More information about the Digitalmars-d mailing list