February 11, 2009
Walter Bright, el 10 de febrero a las 17:16 me escribiste:
> >>>Duplicating (nearly all of a) source file is NOT, repeat NOT, a
> >>>satisfatory solution.
> >>I'm not insensitive to this as I do it myself in maintaining Phobos. It is a problem, but not a huge one. I find that the meld utility (on linux) makes this chore a snap.
> >Because of D's limited support for text macros, I am using third party tools to get me out of this problem too.
> 
> meld is particularly nice. Andrei showed it to me:
> 
> http://www.linux.com/feature/61372

You should probably distribute meld with DMD then ;)

-- 
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
----------------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------------
Hey you, out there on your own
Sitting naked by the phone
Would you touch me?
February 11, 2009
Walter Bright wrote:
> Don wrote:
>> Walter Bright wrote:
>>> This is to combat the pernicious problem of having features that subtract code <g>.
>>
>> I've got two words for you, Walter.
>> Compiler bugs.
> 
> I've never heard of those before. Are they like VW Bugs?

Yes, but they're not as cute.
February 11, 2009
Jarrett Billingsley wrote:
> If nothing - NOTHING - else, please give us version(!something).  Out of everything wrong with it, that is the worst.  You say that according to "cognitive studies" that people don't see the !; then why didn't you remove it from the rest of the language?  And how is THIS:
> 
> version(Poopy) {} else
> {
> 
> }
> 
> supposedly better?!

version(!Windows)
    // some added functionality that depends on UNIX-like semantics

Then port the code to something oddball—Plan 9, say, or VMS.

—Joel Salomon
February 11, 2009
On Wed, Feb 11, 2009 at 9:49 AM, Joel C. Salomon <joelcsalomon@gmail.com> wrote:
> version(!Windows)
>    // some added functionality that depends on UNIX-like semantics
>
> Then port the code to something oddball—Plan 9, say, or VMS.

I use versions for things other than platform-specific code.  Like library compilation options.
February 11, 2009
Jarrett Billingsley wrote:
> I use versions for things other than platform-specific code.  Like library compilation options.

So what would your use-case look like?

—Joel Salomon
February 11, 2009
On Wed, Feb 11, 2009 at 2:14 PM, Joel C. Salomon <joelcsalomon@gmail.com> wrote:
> Jarrett Billingsley wrote:
>> I use versions for things other than platform-specific code.  Like library compilation options.
>
> So what would your use-case look like?

version(TurnOffSomeFeature) {} else
{
    codeForFeature();
}

Sometimes you want to have things that turn _off_ code from a default of being on.

I know, I know, Walter said that "[v]ersions should be positive things, because a version is something that is being build - one doesn't craft a makefile to build a notLinux."  But the fact is, platform-specific stuff and code options are two very different use cases.  Platform-specific things are completely invisible to the user of a library and only one configuration can ever be in use on a single platform.  Code options, on the other hand, are based on user preference.  Some things are extra, and it makes sense to have switches to turn them on.  But some things are the other way, where you want them *on* by default and want to have the option of turning them *off*.
February 11, 2009
Jarrett Billingsley wrote:
> version(TurnOffSomeFeature) {} else
> {
>     codeForFeature();
> }
> 
> Sometimes you want to have things that turn _off_ code from a default
> of being on.
> 
> I know, I know, Walter said that "[v]ersions should be positive
> things, because a version is something that is being build - one
> doesn't craft a makefile to build a notLinux."  But the fact is,
> platform-specific stuff and code options are two very different use
> cases.  Platform-specific things are completely invisible to the user
> of a library and only one configuration can ever be in use on a single
> platform.  Code options, on the other hand, are based on user
> preference.  Some things are extra, and it makes sense to have
> switches to turn them on.  But some things are the other way, where
> you want them *on* by default and want to have the option of turning
> them *off*.

Even if a feature is on by default, versions should still be a positive thing, otherwise you have a double negative:

version (!TurnOffSomeFeature)

Even in regular code, I try to avoid naming things that way, because double negatives are twice as hard to comprehend when things get complicated. I've gone through my code to remove such double negatives as much as possible.

So I suggest:

version (SomeFeature)
{
    codeForFeature();
}

is clearer, even if SomeFeature is the default.
February 11, 2009
Anders F Björklund wrote:
> Walter Bright wrote:
> 
>> Now let's try the other way. I add O_APPEND to the linux branch, and linux works great. Now I port to OSX, and the compiler dies with "O_APPEND is undefined". I know immediately exactly what is wrong, look up the .h file, and insert the right O_APPEND into the OSX version of the declaration.
> 
> Maybe I'm missing something here, but why is Mac OS X including
> std.c.linux.linux ? Shouldn't it use std.c.darwin.darwin instead ?

You're not missing anything. This needs to be cleaned up. (BTW, it will be osx, not darwin, as "darwin" seems to be only used in internal Apple documentation, whereas the published stuff says "OSX".)


>> Furthermore, when I build a FreeBSD version, the compiler bings at me for every declaration that needs some porting attention, instead of silently using the wrong values.
> 
> GDC got tired of porting std.c.linux.linux over, so it generates a
> std.c.unix.unix module from the C headers at configure time instead.
> 
> Also helps with the constants that have different values for different
> architectures, in addition to having different values for different OS.

Doing it automatically is better, of course.

February 11, 2009
Leandro Lucarella wrote:
> You should probably distribute meld with DMD then ;)

sudo apt-get install meld

isn't that hard <g>.
February 11, 2009
Walter Bright skrev:

>> Maybe I'm missing something here, but why is Mac OS X including
>> std.c.linux.linux ? Shouldn't it use std.c.darwin.darwin instead ?
> 
> You're not missing anything. This needs to be cleaned up. (BTW, it will be osx, not darwin, as "darwin" seems to be only used in internal Apple documentation, whereas the published stuff says "OSX".)

"darwin" is the uname(1) name of Mac OS X, sort of like the
"linux" for GNU/Linux. Darwin is also a stand-alone OS, but
that isn't used much anymore (but still available from Apple
as a CD download, or from the http://puredarwin.org project).

OSX is the new name for Apple's OSes: Mac OS X and iPhone OS.

And of course DMD can use anything, but GDC uses darwin/Unix.

--anders


PS. I personally think it looks bad, but it is slightly better
    than OS/X at least (which makes you think of OS/2 Warp)