Conditional compilation inside asm and enum declarations

Bill Baxter wbaxter at gmail.com
Tue Jul 14 17:15:33 PDT 2009


On Tue, Jul 14, 2009 at 5:02 PM, Walter
Bright<newshound1 at digitalmars.com> wrote:
> Bill Baxter wrote:
>>
>> You do realize you're being patronizing, right?  "I have so much
>> experience with these things, and I know the right way to write code,
>> and you don't, so I'm not going to give you this thing you request
>> because it's not good for you".
>
> Sure. There's some of that in every language. They all have some feature or
> other rejected because the designers, be they individuals or committees,
> considered such features as encouraging bad practice.
>
> Even C++ has this. Why do you think doing | operations on pointers is
> illegal? It's certainly not a limitation on compiler technology, and there
> certainly are legitimate uses for it. But the designers felt that was an
> execrable practice that should be banned.
>
> The resumption exception handling model for C++ was rejected because it was
> felt such encouraged bad practices.
>
>> Also note that despite D's limitations supposedly making things
>> better, you just got through describing how parts of Phobos turned
>> into a mess anyway.
>
> It's not as good as I would like it to be, but it's also not near as bad
> with conditional compilation as other libraries I've dealt with.
>
>
>> So not only do the little missing capabilities annoy people who would
>> use them judiciously, they also apparently don't have the desired
>> outcome of eliminating poor use of conditional compilation.  Sounds
>> like something you would find in a patronizing nanny-language to me.
>> Which is odd, because D isn't like that, overall.
>
> Rather than interpret it as patronizing, I ask you to try it my way for a
> while. Give it a fair shake.


I think your way is fine.  But I also think that there are lots of
versions that are binary in nature, like "version(HaveSomeAPI)", where
the natural thing to do to supplant the functionality is

version(!HaveSomeAPI) {
    // replacement implementation of SomeAPI goes here
}

and not

version(HaveSomeAPI) {} else {
    // replacement implementation of SomeAPI goes here
}

and also not

version(HaveSomeAPI) {} else {
     version = HaveNotSomeAPI;
}
version(HaveNotSomeAPI) {
    // replacement implementation of SomeAPI goes here
}

I'm not arguing with you about the big picture of how to organize
non-trivial conditional versioning.  I'm more arguing that removing !
from version does little to encourage good coding practices and plenty
to hinder reasonable ones.

Anyway, I don't expect you to change your mind since we've pretty much
been over all this before, so I'll leave it be at this.

--bb



More information about the Digitalmars-d mailing list