Re: Detecting the Eu version
- Posted by Jason Gade <jaygade at yahoo.com> Dec 16, 2004
- 582 views
Derek Parnell wrote: > > Jason Gade wrote: > > [snip] > > > Okay. Even though I wanted to kill this thread a few hours ago my interest > > is piqued > > now that I see more nuance in it. How do other languages handle this > > situation? Most > > of us know how C/C++ handles it (with #ifdef). What about Python, Ruby, > > Lua, or Perl? > > The D language has a 'version()' directive which is very versitile. > > if version(2.5) { > .. . . > } > else > { . . . } > > But you can also do things like ... > > if version(myspecial) { } > > On the command line you can do ... > > dmd -version=myspecial > > And even inside the code you can do ... > > version = abc; > . . . > if version(abc) { } > > It's great for temporarily commenting out nested lines... > > if version(COMMENTOUT) { > int a = 1; > if version(COMMENTOUT) { > float b = 2.3; > } > } > > The 'version()' is processed by the parser and thus you can get it > to include or exclude compilable code in a very flexible and intuitive > manner; so don't expect this from RDS anytime soon. > > -- > Derek Parnell > Melbourne, Australia > Yeah, I was aware of D's version() feature... it's pretty cool. But you would still have to write parallel code to implement future features while retaining backward compatability. It is still a very useful thing, though. ===================================== Too many freaks, not enough circuses. j.