D - version bites again ...
- Matthew (65/67) Dec 18 2003 I can't do the following:
- J Anderson (40/63) Dec 18 2003 //Or even allowing this IMHO slightly more sival syntax:
- Ant (43/110) Dec 18 2003 I would do it like this:
- Matthew (6/131) Dec 18 2003 Well, yeah, of course I've done it like that. ;)
- C. Sauls (21/21) Dec 18 2003 Did you try:
- Matthew (5/26) Dec 18 2003 You'd need to have the usage() call within it, I think.
- Walter (30/95) Dec 18 2003 Frankly, I think the latter one is more readable than either of the form...
I can't do the following: int main(char[][] args) { if( args.length > 1 && version(Windows) { ( args[1][0] == '-' || args[1][0] == '/') && } else { args[1][0] == '-' && } args[1][1] == '?') { usage(); } return 0; } Is there no way that the braces for the version statement can be changed such that they're not part of normal code syntax? What about int main(char[][] args) { if( args.length > 1 && version(Windows) [< ( args[1][0] == '-' || args[1][0] == '/') &&]else [< args[1][0] == '-' &&]args[1][1] == '?') { usage(); } return 0; } or something similar. As it is I have to write it like: int main(char[][] args) { version(Windows) { if( args.length > 1 && ( args[1][0] == '-' || args[1][0] == '/') && args[1][1] == '?') { usage(); } } else { if( args.length > 1 && args[1][0] == '-' && args[1][1] == '?') { usage(); } } return 0; } which is positively giving the middle finger to the ODR. :( Matthew
Dec 18 2003
Matthew wrote:I can't do the following: int main(char[][] args) { if( args.length > 1 && version(Windows) { ( args[1][0] == '-' || args[1][0] == '/') && } else { args[1][0] == '-' && } args[1][1] == '?') { usage(); } return 0; } Is there no way that the braces for the version statement can be changed such that they're not part of normal code syntax? Matthew//Or even allowing this IMHO slightly more sival syntax: int main(char[][] args) { if(args.length > 1) version(Windows) { if(args[1][0] == '-' || args[1][0] == '/') } else { if (args[1][0] == '-') } if (args[1][1] == '?') { usage(); } } return 0; } You could do this: if( args.length > 1 && args[1][1] == '?') { if (args[1][0] == '-' ) { usage(); } else { version (Windows) { if (args[1][0] == '/') { usage(); } } } } But I know what you mean. -Anderson
Dec 18 2003
In article <brt3su$1ejg$3 digitaldaemon.com>, Matthew says...I can't do the following: int main(char[][] args) { if( args.length > 1 && version(Windows) { ( args[1][0] == '-' || args[1][0] == '/') && } else { args[1][0] == '-' && } args[1][1] == '?') { usage(); } return 0; } Is there no way that the braces for the version statement can be changed such that they're not part of normal code syntax? What about int main(char[][] args) { if( args.length > 1 && version(Windows) [< ( args[1][0] == '-' || args[1][0] == '/') &&I would do it like this: module somewhere; version linux { bool isCommandLineSwitch... } else { //you get the idea... } module myApp; import somewhere; int main(char[][] args) { // see how much easy to understand this is? if ( args.length > 1 && somewhere.isCommandLineSwitch(args[1][0]) && args[1][1] = '?' ) { usage(); } } In other words, beside other problems, you're doing a common test at the prog level instead of some lib level. maybe module somewhere could be part of phobos. maybe we can create another common sense rule: if the version doesn't fit your program probably your prog should be reviwed. (maybe not... ;) maybe you are right and just unlucky selecting the example... but I think giving that flexibility to version will make people abuse it and create unreadble, unmaintainable progs. Perheaps that is desirable(?). Ant PS after reading my post it sounds rude. Sorry I don't mean that, please forgive my limitation with English.]else [< args[1][0] == '-' &&]args[1][1] == '?') { usage(); } return 0; } or something similar. As it is I have to write it like: int main(char[][] args) { version(Windows) { if( args.length > 1 && ( args[1][0] == '-' || args[1][0] == '/') && args[1][1] == '?') { usage(); } } else { if( args.length > 1 && args[1][0] == '-' && args[1][1] == '?') { usage(); } } return 0; } which is positively giving the middle finger to the ODR. :( Matthew
Dec 18 2003
"Ant" <Ant_member pathlink.com> wrote in message news:brt7ro$1kii$1 digitaldaemon.com...In article <brt3su$1ejg$3 digitaldaemon.com>, Matthew says...Well, yeah, of course I've done it like that. ;) But there are going to be countless cases where using {} braces for version and for code is going to cause problems.I can't do the following: int main(char[][] args) { if( args.length > 1 && version(Windows) { ( args[1][0] == '-' || args[1][0] == '/') && } else { args[1][0] == '-' && } args[1][1] == '?') { usage(); } return 0; } Is there no way that the braces for the version statement can be changed such that they're not part of normal code syntax? What about int main(char[][] args) { if( args.length > 1 && version(Windows) [< ( args[1][0] == '-' || args[1][0] == '/') &&I would do it like this: module somewhere; version linux { bool isCommandLineSwitch... } else { //you get the idea... } module myApp; import somewhere; int main(char[][] args) { // see how much easy to understand this is? if ( args.length > 1 && somewhere.isCommandLineSwitch(args[1][0]) && args[1][1] = '?' ) { usage(); } } In other words, beside other problems, you're doing a common test at the prog level instead of some lib level.]else [< args[1][0] == '-' &&]args[1][1] == '?') { usage(); } return 0; } or something similar. As it is I have to write it like: int main(char[][] args) { version(Windows) { if( args.length > 1 && ( args[1][0] == '-' || args[1][0] == '/') && args[1][1] == '?') { usage(); } } else { if( args.length > 1 && args[1][0] == '-' && args[1][1] == '?') { usage(); } } return 0; } which is positively giving the middle finger to the ODR. :( Matthewmaybe module somewhere could be part of phobos. maybe we can create another common sense rule: if the version doesn't fit your program probably your prog should be reviwed. (maybe not... ;) maybe you are right and just unlucky selecting the example... but I think giving that flexibility to version will make people abuse it and create unreadble, unmaintainable progs. Perheaps that is desirable(?). Ant PS after reading my post it sounds rude. Sorry I don't mean that, please forgive my limitation with English.Duck. Back. Water. :)
Dec 18 2003
In article <brt88c$1l8c$2 digitaldaemon.com>, Matthew says...(Just to remind everybody of the comunication dificulties on this multicultural thing) I have no idea what you mean so I tried google and got: "water off a duck’s back To fail to catch on or make a mark: “The reporter’s snide comments rolled off the candidate like water off a duck’s back.” " I can also get it like: Duck - someone is trying to hide Back - and run away Water - but hit the water = humiliation ???????? :) Antplease forgive my limitation with English.Duck. Back. Water. :)
Dec 18 2003
off(Just to remind everybody of the comunication dificulties on this multicultural thing) I have no idea what you mean so I tried google and got: "water off a duck's back To fail to catch on or make a mark: "The reporter's snide comments rolledplease forgive my limitation with English.Duck. Back. Water. :)the candidate like water off a duck's back." " I can also get it like: Duck - someone is trying to hide Back - and run away Water - but hit the water = humiliation ???????? :)I wasn't implying you were snide. That quote's not the best. "Like water off a duck's back" is an English expression meaning that whatever discomfiture might be experienced can be borne with ease. In other words, you don't need to apologise about a potential small offence, as it won't bother me. (And I'm wont to offend in small ways myself. ;) Cheers Matthew
Dec 18 2003
Did you try: int main (char[][] args) { version(Windows) { if ( args.length > 1 && (args[1][0] == '-' || args[1][0] == '/') && args[1][1] == '?' )} else { if ( args.length > 1 && args[1][0] == '-' && args[1][1] == '?' )} { usage() } return 0; } Its not a thousand times better, but I think it should work. -- C. Sauls -- Invironz
Dec 18 2003
You'd need to have the usage() call within it, I think. Short answer, no, I didn't. :) "C. Sauls" <ibisbasenji yahoo.com> wrote in message news:brt7tj$1kmk$1 digitaldaemon.com...Did you try: int main (char[][] args) { version(Windows) { if ( args.length > 1 && (args[1][0] == '-' || args[1][0] == '/') && args[1][1] == '?' )} else { if ( args.length > 1 && args[1][0] == '-' && args[1][1] == '?' )} { usage() } return 0; } Its not a thousand times better, but I think it should work. -- C. Sauls -- Invironz
Dec 18 2003
"Matthew" <matthew.hat stlsoft.dot.org> wrote in message news:brt3su$1ejg$3 digitaldaemon.com...I can't do the following: int main(char[][] args) { if( args.length > 1 && version(Windows) { ( args[1][0] == '-' || args[1][0] == '/') && } else { args[1][0] == '-' && } args[1][1] == '?') { usage(); } return 0; } Is there no way that the braces for the version statement can be changed such that they're not part of normal code syntax? What about int main(char[][] args) { if( args.length > 1 && version(Windows) [< ( args[1][0] == '-' || args[1][0] == '/') &&Frankly, I think the latter one is more readable than either of the former two examples. But I would write it as: int main(char[][] args) { if (args.length > 1) { switch (args[1]) { version (Windows) { case "/?": } case "-?": usage(); break; } } return 0; } To embed versions into expressions, you can write: bit slash = false; version (Windows) slash = true; // support slash style switches if (args.length > 1 && ((slash && args[1] == "/?") || args[1] == "-?")) Note that the optimizer will recognize that slash is a constant, and will optimize away that test and any dependent expressions on it that will never be evaluated.]else [< args[1][0] == '-' &&]args[1][1] == '?') { usage(); } return 0; } or something similar. As it is I have to write it like: int main(char[][] args) { version(Windows) { if( args.length > 1 && ( args[1][0] == '-' || args[1][0] == '/') && args[1][1] == '?') { usage(); } } else { if( args.length > 1 && args[1][0] == '-' && args[1][1] == '?') { usage(); } } return 0; } which is positively giving the middle finger to the ODR.
Dec 18 2003