minwin
Georg Wrede
georg.wrede at nospam.org
Wed Nov 29 08:41:15 PST 2006
Walter Bright wrote:
> Tomas Lindquist Olsen wrote:
>
>> version(Windows || linux)
>> {
>> ...
>> }
>> else
>> {
>> ...
>> }
>>
>> is clearer IMHO.
>
>
> That is certainly seductive and it's hard to see what's wrong with it.
> But I've seen what it inevitably leads to - an ugly, incomprehensible
> mess that is invariably wrong. It's often so bad that I have to run the
> preprocessor just to figure out which pieces of the code are actually
> being compiled! I haven't seen one yet that couldn't stand being
> reevaluated.
>
> If you find wanting && and || and ?: and ! in the versions, I suggest
> one the following:
>
> 1) reevaluate just what feature it is you're testing for, and create a
> version identifier for that feature.
>
> 2) abstract the version differences away in a separate module.
>
> Sure, it requires a little more work and a little more thought. But I
> think it's worth it, it's certainly been so when I've used that approach.
Sometimes a common problem suggests a solution so that everybody in the
audience invents more or less the same thing. When it doesn't seem to
have immediate downsides, there'll be unanimous demand for it.
If the man on the stage doesn't shoot down the solution vigorously
enough, there will eventually be a riot demanding implementation.
At the end of the day, only historians will eventually sort out who was
right each time.
---
This compiling conditionals issue, IMHO, is what Walter really has been
doing all his life. And such Experience is invaluable when the downsides
are not obvious enough to even seasoned programmers. In one sense,
that's the whole point of demanding experience when hiring people.
More information about the Digitalmars-d-announce
mailing list