Why version() ?

Nick Sabalausky a at a.a
Tue Feb 10 17:31:13 PST 2009


"Walter Bright" <newshound1 at digitalmars.com> wrote in message 
news:gmt1s1$i7f$1 at digitalmars.com...
> Nick Sabalausky wrote:
>> This strikes me as throwing away the baby with the bathwater. If your 
>> code starts degenerating towards a versioning rat's nest, then the 
>> solution is to take a moment and refactor it into a larger granularity, 
>> not to throw away features that are useful in moderation.
>
> True, but that never, ever happens. It's always "I can get my few 
> additions to this rat's nest in and just get it working, and worry about 
> proper abstraction later."
>

It seems to me that D's versioning, conditional compilation, and overall 
feature set are already different enough that people aren't necessarily 
going to be falling into the "c preprocessor style" rut. Plus, as someone 
else mentioned, there *are* still concerns about code duplication. So it 
really becomes a balancing act between clear abstraction and DRY. D's 
version() just makes this balancing act harder because it keeps pushing in 
the one direction.

I'll grant that if there's a bad habit that most coders are doing (such as 
messy versioning), then it's certainly worthwhile to create a design that 
prevents it. But the more I think about it, the more convinced I become that 
most of version()'s restrictions are just red herrings. I really think 
you're attacking the wrong thing (not that I have any idea where the ideal 
place to attack would be). After all, Denis and I have both demonstrated 
that D's version() is just as susceptible to mess as C's #if/#ifdef 
versioning. If people are going to make a version() mess, they're going to 
do it. Things like !, ||, && and expression-level versions are just drops in 
the pond, they would allow certain things to be cleaned up, but they're not 
going to break the dam any more than it already is, and they would even make 
a few things better.

It would be great to have a way to eliminate messy versioning, but things 
such as prohibiting !, ||, && and expression-versions are doing very little 
to accomplish that. Modeling the version() syntax after the conditional 
syntax, and giving it less-than-"BEGIN"->"{"-level of power is already 
accomplishing far more in that regard. The benefits of preventing typos in 
version identifiers would also dwarf any benefits that might be gained from 
prohibiting !, ||, && and expression-versions.





More information about the Digitalmars-d mailing list