Versioning best practices
Thomas Kuehne
thomas-dloop at kuehne.cn
Wed Jan 24 11:20:58 PST 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Lars Ivar Igesund schrieb am 2007-01-24:
> I've been looking at what D and the compilers provide to help with
> successfully versioning D source code in such a way that it minimizes
> duplication of code (and in the process ease organization of said code),
> ease readability and ease building.
[...]
> Do you think that the current tools are adequate?
Most of the times versioning is the wrong approach. I think C's
(and to a lesser extend C++'s) non-existing compile time reflection
forced everyone to use versioning instead of "featuring".
I'll use Flectioned[1] as a sample.
the problem: support 5 different D APIs
* dmd-1.001
* dmd-1.00
* dmd-0.177
* gdmd-0.21
* gdmd-0.20
("Normal" programs shouldn't notice the differences, they are however
crucial for Flectioned.)
the solution:
* targeted operation system / binary format
# flectioned.d:755: version(linux){
* new GC features
# flectioned.d:495: static if(is(typeof(si.flags)))
* changed member names for some TypeInfo classes
# flectioned.d:1443: static if(is(typeof((new typeof(ti)()).value)))
The rest is done with generic logic that handles issues like mangling
bugs without requiring "static if" or "version".
Thomas
[1] runtime reflection for D:
http://svn.dsource.org/projects/flectioned/downloads/flectioned.zip
-----BEGIN PGP SIGNATURE-----
iD8DBQFFt72BLK5blCcjpWoRAmqFAJwLl/JxUvleQOZg8Hp0Kobe1RK5AACeOiqm
ksJcBKVM89w4qa3fwbffOh4=
=Ezzn
-----END PGP SIGNATURE-----
More information about the Digitalmars-d
mailing list