Version block "conditions" with logical operators

Jonathan M Davis newsgroup.d at jmdavisprog.com
Fri Dec 14 02:20:09 UTC 2018


On Thursday, December 13, 2018 5:45:10 PM MST Andrew Pennebaker via 
Digitalmars-d wrote:
> On Wednesday, 11 May 2016 at 17:02:36 UTC, bitwise wrote:
> > Still holding out hope Walter will change his mind here..
> >
> > His rationale is based on keeping code clean and organized, but
> > given that D has no preprocessor macros, it will never look as
> > bad as C++ code, or even close.
> >
> > Compounding versions in C++ accounts for a very small portion
> > of the mess. When you have an #if VERS every 5 lines, however,
> > you've got a problem...but then, you can do that with D's
> > version just the same. The real solution is to properly
> > encapsulate system-dependant code so that whatever version
> > statement you need, is all in one place. Also when you have to
> > hack 10 different macros together to invent a feature your
> > language doesn't have, you've got a problem, but this is much
> > less of a concern in D than C++.
> >
> > When even D gurus writing D compilers have to hack solutions
> > together with static if to get by, its time to re-evaluate the
> > situation.
> >
> >    Bit
>
> Most things aside from straight up
>
> version([!]condition [op condition... [op condition...]) { ... }
> [else { ... }]
>
> are going to lead to surprising behavior, bad code, and gnashing
> of teeth. We shouldn't have to resort to macros to do this.

You might want to pay attention to the date of the post that you're replying
to. It's about two-and-a-half years old.

- Jonathan M Davis





More information about the Digitalmars-d mailing list