February 15, 2009
Anders F Björklund wrote:
> But yeah, it would be nice if DMD could set both "version(darwin)"
> and "version(OSX)" for Mac OS X. That way the old code would work too.

LDC will also add the OSX version specifier for Mac OS X.

Christian

February 16, 2009
Tue, 10 Feb 2009 13:34:35 +0100, grauzone wrote:

> Frits van Bommel wrote:
>> grauzone wrote:
>>> Some severe disadvantages of version():
>>> 1. They can't contain expressions (like "version(linux && mac)").
>> 
>> Unless Apple has plans to s/BSD/Linux/ in MacOS that I'm not aware of, version(linux || mac) would probably be more useful...
>> 
>> Allowing boolean expressions (using only version identifiers) in version() would be a very welcome feature.
>> 
>> I'm not sure about the rest of your post though.
> 
> Well, my argument is that CTFE already provides all version features and even more. version is redundant, and even dangerous, because it can't catch typos in version identifiers.
> 
> Actually, C/C++ has something similar: #if (is similar to static if) versus #ifdef (is similar to version). ffmpeg recently switched from using #ifdef to #if.

#if is no different from #ifdef because any undefined identifier evaluates to 0 within the #if context.
February 16, 2009
Tue, 10 Feb 2009 19:57:47 -0800, Walter Bright wrote:

> Nick Sabalausky wrote:
>> I have to admit, that's a very compelling example. I hadn't thought of anything like that.
> 
> I didn't either, until I got bit by it <g>.
> 
>> I guess the moral is "DRY is normally great, but be very careful with it when using it across multiple builds." But I'm still not sure we should be going that far. For instance:
>> 
>> enum
>> {
>>     version(Linux || OSX)
>>     {
>>         O_RDONLY = 0,
>>         O_WRONLY = 1,
>>         O_RDWR = 2,
>>         O_CREAT = 0100,
>>     }
>>     version(Linux)
>>     {
>>         O_APPEND = 02000,
>>     }
>>     version(OSX)
>>     {
>>         O_APPEND = 8,
>>         O_SYMLINK = 0x200000,
>>     }
>> }
>> 
>> That seems reasonable to me.
> 
> Yeah, but I guarantee you that there will be some "common to all" ones and an irresistible temptation to put them in outside any version block. I also like to have all the enums for one platform in one list, not broken up by other stuff for other platforms, because then it is easier to verify against the C headers.
> 
>> Besides, without expression-level version(), the project's author might just as likely think "Shoot, this is stupid that D doesn't let me make this nicely DRY. But I really like DRY, so I guess I'll just resort to an external C-like pre-processor".
> 
> There's something wrong with that option, because although it's always been on the table (not just for D, but for any language) nobody ever uses it.

There's Antenna for Java.  It's nearly impossible to do without some preprocessor in Java if you want some mid-level library to work reliably on many different mobile phones.  Compile once, run anywhere--sounds like a joke to me.
3 4 5 6 7 8 9 10 11 12 13
Next ›   Last »