Thread overview | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
September 23, 2008 [Issue 2370] New: Version statement enhancement: versioned identifiers | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=2370 Summary: Version statement enhancement: versioned identifiers Product: D Version: unspecified Platform: PC OS/Version: Windows Status: NEW Severity: enhancement Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: snake.scaly@gmail.com I propose version identifiers to have a numeric value and to add the following version statement syntax: VersionCondition: version ( Identifier, Integer ) This version condition is satisfied when the Identifier's value is equal or greater than the Integer. This way, the code in version (D_Version, 2) { ... } will be compiled only when the compiler version is 2 or greater. The version specification syntax can be VersionSpecification: version = Identifier ( Integer ) ; -- |
September 23, 2008 [Issue 2370] Version statement enhancement: versioned identifiers | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2370 ------- Comment #1 from jarrett.billingsley@gmail.com 2008-09-22 22:27 ------- Please please please. It seems odd that such an obvious use of preprocessor macros for versioning was not carried forward into D. -- |
September 23, 2008 [Issue 2370] Version statement enhancement: versioned identifiers | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2370 ------- Comment #2 from benoit@tionex.de 2008-09-23 03:41 ------- This would have helped me a lot in the past. -- |
September 23, 2008 [Issue 2370] Version statement enhancement: versioned identifiers | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2370 shro8822@vandals.uidaho.edu changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |shro8822@vandals.uidaho.edu ------- Comment #3 from shro8822@vandals.uidaho.edu 2008-09-23 13:34 ------- Vote += Lots -- |
October 03, 2008 [Issue 2370] Version statement enhancement: versioned identifiers | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2370 brunodomedeiros+bugz@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |brunodomedeiros+bugz@gmail.c | |om ------- Comment #4 from brunodomedeiros+bugz@gmail.com 2008-10-03 10:04 ------- Like I said in the original thread, isn't it enough to have: version(D_Version_2OrAbove) { ... ? Or just version(D_Version1) { ... } else { //version 2 or above here... } ? It doesn't seem this feature is justified. -- |
October 03, 2008 [Issue 2370] Version statement enhancement: versioned identifiers | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2370 ------- Comment #5 from snake.scaly@gmail.com 2008-10-03 10:53 ------- (In reply to comment #4) > Like I said in the original thread, isn't it enough to have: > version(D_Version_2OrAbove) { ... > ? > Or just > version(D_Version1) { > ... > } else { > //version 2 or above here... > } > ? > It doesn't seem this feature is justified. Imagine I've got MyLib v.21. There was nice API introduced in v.17 and I have a special cased code which should work from version 17 on. In my approach: module myapp; import mylib; version(MyLib, 17) { NiftyMyLibCall(); } else { ...lots of code... } module mylib; version = MyLib(21); In your approach I'm either going to have 21 version statements in mylib which is tedious, error-prone and is hardly automated, or I must have 5 version clauses in my source which all mix in the same piece of code and I must add new version clause every time a new version of lib is published. -- |
October 03, 2008 [Issue 2370] Version statement enhancement: versioned identifiers | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2370 ------- Comment #6 from brunodomedeiros+bugz@gmail.com 2008-10-03 11:31 ------- If you add a specific feature in a given version, it's best (clearer) to add a: version = NiftyMyLibCallAvailable; and then use: version(NiftyMyLibCallAvailable) { NiftyMyLibCall(); } instead of version numbers. In any case, when releasing a new version: Your approach: * go to the 'version = MyLibVersion(20);' statement * change it to 'version = MyLibVersion(21);' My approach: * go to the 'version = MyLibVersion20OrAbove;' statement * add a 'version = MyLibVersion21OrAbove;' statement How is my approach any more tedious, error-prone, or less automated? They are both one line changes you have to make (mine has an extra copy&paste), and they are both dead easy to make. My approach may end up with more code written, but that's hardly ever more error-prone, since that code is not supposed to change or be maintained (one doesn't usually downgrade the version number of a lib). -- |
October 03, 2008 [Issue 2370] Version statement enhancement: versioned identifiers | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2370 ------- Comment #7 from snake.scaly@gmail.com 2008-10-03 15:46 ------- (In reply to comment #6) > If you add a specific feature in a given version, it's best (clearer) to add a: > version = NiftyMyLibCallAvailable; > and then use: > version(NiftyMyLibCallAvailable) > { > NiftyMyLibCall(); > } > instead of version numbers. Is there *any* library around that has a version/#define for every single interface and every single change in that interface? I don't think so, it's just not feasible. > In any case, when releasing a new version: > Your approach: > * go to the 'version = MyLibVersion(20);' statement > * change it to 'version = MyLibVersion(21);' > > My approach: > * go to the 'version = MyLibVersion20OrAbove;' statement > * add a 'version = MyLibVersion21OrAbove;' statement > > How is my approach any more tedious, error-prone, or less automated? They are both one line changes you have to make (mine has an extra copy&paste), and they are both dead easy to make. My approach may end up with more code written, but that's hardly ever more error-prone, since that code is not supposed to change or be maintained (one doesn't usually downgrade the version number of a lib). A version number in one particular place can be replaced by a script, or by a version control system. It's significantly harder to add a line automatically. Though adding a line for every version is definitely much better than adding a version statement for every interface change. -- |
October 03, 2008 [Issue 2370] Version statement enhancement: versioned identifiers | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2370 ------- Comment #8 from shro8822@vandals.uidaho.edu 2008-10-03 15:55 ------- 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. importer.d: import imported; version(bob) { pragma(msg,"bob"); } else { pragma(msg,"!bob"); } imported.d: version = bob; output: !bob -- |
October 03, 2008 [Issue 2370] Version statement enhancement: versioned identifiers | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2370 ------- Comment #9 from snake.scaly@gmail.com 2008-10-03 16:10 ------- (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. You're right. This is a very strange and undocumented behavior. Well, this adds more value to my proposal: writing 21 version statements in command line is... well, tedious. -- |
Copyright © 1999-2021 by the D Language Foundation