[Issue 2370] Version statement enhancement: versioned identifiers

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Oct 15 08:12:37 PDT 2008


http://d.puremagic.com/issues/show_bug.cgi?id=2370





------- Comment #13 from brunodomedeiros+bugz at gmail.com  2008-10-15 10:12 -------
(In reply to comment #8)
> Several of the comments seem to be forgetting that "version = bob" in an
> imported file has no effect on "version(bob)" statements in the importing file.
> 

In fact, I think this fact alone shows that D's version statement mechanism
should not be used for version management of user libraries, but only runtime
related aspects (the platform/CPU, the compiler, the D version, etc.)

For user libraries, I would suggestion using (manifest) constants to define the
lib version, and users of you library could use static if to perform tasks
depending on the existing version (including compile-time duck typing like
code). Example:

  static if(OpenGL.VersionMajor == 2) {
    ...

  static if(is(com.foo.MyLib.myXptoFunc)) { // check if myXptoFunc is available
    ...


-- 



More information about the Digitalmars-d-bugs mailing list