Why version() ?
Nick Sabalausky
a at a.a
Tue Feb 10 19:18:54 PST 2009
"Walter Bright" <newshound1 at digitalmars.com> wrote in message
news:gmtatl$12om$2 at digitalmars.com...
> Nick Sabalausky wrote:
>> The point is, the current semantics for D's version() are *plenty*
>> susceptible to most of same versioning mess as C's #if/#ifdef, and in
>> some cases (such as ||), even worse. With either style, the solution is
>> exactly the same as any other chunk of messy code: Clean it up! Not only
>> is gimping the version-control mechanism the wrong solution, it doesn't
>> even solve the problem anyway.
>
> I'll argue that I've never seen anyone create such a mess in D, while I
> see it regularly in C.
Agreed, but I'm certain that a significant reason for that is the fact that
(and I mean no disrespect to D by this) C has had far more people working on
a far larger number of projects that each span far more platforms all for a
far longer time. Just look at all of the platforms supported by that GC
example. Even the D language itself isn't that multi-platform yet. And then
there's all of that GNU C code that's been around much longer than even D
itself.
If D had the ubiquity of C (as I hope someday it will), then D would have
plenty of mess too. Not as much, granted (for reasons I argue below), but
still a fair amount.
> So something about D is discouraging developing those things.
>
> I think the tipping point is that it's too easy in C to slip into writing
> such a mess without actually trying to, while in D you have to work harder
> to do it.
I agree there are things about D that discourage such messy tactics, but I
don't think it's the lack of !, ||, && and expression-level usage. I think,
as Steven said, that the discouragement comes more from version() being a
syntactic/semantic part of the language itself instead of a blunt
text-replacement engine that neither knows nor cares what it tramples over.
That's why you have to work harder to make a conditional-compilation mess,
not because it lacks a few features.
Plus, the C preprocessor's syntax automatically invokes a mental association
with "blunt text-editing tool" and I think that's a big part of why C coders
slip into the mess. D's version() and static if() *look* like an ordinary
if(), so that alone is going to decrease urges to use them like a C
preprocessor.
More information about the Digitalmars-d
mailing list