Bill Baxter wrote:
On Mon, Jul 13, 2009 at 10:05 PM, Walter
Bright<newshou...@digitalmars.com> wrote:
Julian Salazar wrote:
It's been rehashed here several times (not to rag on you, just to point out
that it isn't something that's been overlooked). To sum up, I've worked a
lot with both styles - #ifdef, and separating dependencies into independent
modules. The latter works a lot better. I know it's hard to believe if
you're used to the #ifdef style. I've been doing some work to remove
#ifdef's from the dmd compiler source, and the results so far have been very
satisfactory.
But from where I sit it looked like Walter didn't really convince
anyone. To me this seems like a point where D is overly patronizing,
to use the phrase from a recent post.
FWIW I've recently experimented in Phobos with function-level
versioning, e.g.:
version(Posix) void setenv(in char[] name, in char[] value, bool overwrite)
{
...
}
version(Windows) void setenv(in char[] name, in char[] value, bool
overwrite)
{
...
}
Then I have the function right there with all versioned implementations.
To me that seems better than Phobos' existing style of version'ing large
portions of code, which inevitably results in duplicating a lot of the
functionality in two places.
One other thing I like about the approach above is that it does not
necessitate an extra level of indentation, and it doesn't make you feel
guilty for not adding it. I cringe whenever I see at the top level:
version (something)
{
non_indented_stuff
more_non_indented_stuff
etc
}
Andrei