Why version() ?

Steven Schveighoffer schveiguy at yahoo.com
Tue Feb 10 18:19:27 PST 2009


"Walter Bright" wrote
> Nick Sabalausky wrote:
>> "Walter Bright" <newshound1 at digitalmars.com> wrote in message 
>> news:gmt6l0$rff$1 at digitalmars.com...
>>> Denis Koroskin wrote:
>>>> Does it look any better? No way!
>>> Of course doing it that way doesn't look any better, because it still 
>>> just replicates the C preprocessor style of doing it.
>>>
>>
>> Which just goes to show that the restrictions you've placed on D's 
>> version() (in order to eliminate rat's nest versioning) DON'T eliminate 
>> rat's nest versioning.
>
> But they do make it more painful to write the rat's nest, which can be 
> motivating to find a more appropriate solution.

And when the rats nest MUST be created?  Why make it more painful?  I'm sure 
if Hans Bohem could write it in a clearer fashion he would have.

To be perfectly clear, I absolutely agree with version statements not 
messing with the separation between semantic analysis and parsing, but these 
shortcuts for having multiple version identifiers in one statement do not 
hurt anything.  I contend it is the lack of separation in C's preprocessor 
that makes it difficult to understand, not the lack of requirements on the 
#if itself.  At least, that's what I've always hated about C/C++ 
preprocessor.

The same arguments could be said about actual if statements in code, yet you 
have no qualms not forcing people to combine their logic into boolean 
variables before using an if statement.

>>> A far better solution...
>>
>> And we can come up with better solutions for C as well. Granted, the 
>> optimal D solution is going to be much better than the optimal C 
>> solution, but it won't be due to version()'s lack of !, ||, &&, etc...
>
> When cookies and veggies are laid out on the buffet, I tend to reach for 
> the cookies <g>.

It's more like moldy cookies and half-eaten donuts :)  Neither looks 
appetizing, but when your really hungry...

-Steve 





More information about the Digitalmars-d mailing list