Why version() ?

Steven Schveighoffer schveiguy at yahoo.com
Tue Feb 10 18:11:08 PST 2009


"Walter Bright" wrote
> 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.
>
> A far better solution is to create a series of modules:
>
> gcnetbsd.d
> gchurd.d
> gcsunos5.d
> ...
>
> and inside each one put the specifics for that particular system. The huge 
> advantage of this is that if I want to create a BrightBSD operating 
> system, I just have to write a:
>
> gcbrightbsd.d

All you have done is split the mess into separate files.  This does not 
solve the problem.

> rather than trying to carefully fold it into that conditional compilation 
> mess without inadvertently breaking other platform support. (And I cannot 
> even tell if I broke the SunOS5 platform support or not, because I don't 
> have a SunOS5 platform to test it on.).

But you have, because inadvertently, you changed some code in the actual 
implementation to use the new identifiers you made in your special new file. 
Now you have to go back and rethink the sunos include because you broke it. 
Mess still exists.  (of course, I have no idea, but I gave you as much of an 
example/proof as you did ;)

>> The story is not about different functionality on different platforms but 
>> rather about a common code which is 98% the same on all the platforms and 
>> is different in *small* details.
>> For example, I'd like to make my library D1 and D2 compatible. Do you 
>> suggest me to maintain 2 different libraries? This is ridiculous, and 
>> that's why there is no Tango2 release yet - there is *no* point in 
>> supporting such a large library as Tango (or DWT) for two language 
>> versions without a sane versioning mechanism.
>
> There are two very different things going on here. One is accounting for 
> differences in the *language*, the other is about generating different 
> builds based on language independent different desired features and 
> platform characteristics.

That I would agree, and it turns out your example suffers from the same 
issues, i.e. #if __STDC__

-Steve 





More information about the Digitalmars-d mailing list