www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - version'ing issue

reply "Koroskin Denis" <2korden gmail.com> writes:
This won't compile under D 1.x:

class SomeClass
{
     version( D_Version2 )
     {
         invariant void someMethod()
         {
         }
     } else {
         const void someMethod()
         {
         }
     }
}

int main()
{
     return 0;
}


Maybe 'version'ing should be less restrictive on syntax so that backward  
compatibility could still be possible.
Now I'm a little stuck with porting code from D2.012 to D1.028.

Or should we just choose one version and stick with it?
Mar 29 2008
next sibling parent Derek Parnell <derek psych.ward> writes:
On Sun, 30 Mar 2008 00:14:15 +0300, Koroskin Denis wrote:

 This won't compile under D 1.x:
 
 class SomeClass
 {
      version( D_Version2 )
      {
          invariant void someMethod()
          {
          }
      } else {
          const void someMethod()
          {
          }
      }
 }
 
 int main()
 {
      return 0;
 }
 
 Maybe 'version'ing should be less restrictive on syntax so that backward  
 compatibility could still be possible.
 Now I'm a little stuck with porting code from D2.012 to D1.028.
 
 Or should we just choose one version and stick with it?

The workaround is just plain butt ugly and should be a sameful thing to use. class SomeClass { version( D_Version2 ) { mixin(` invariant void someMethod() { } `); } else { void someMethod() { } } } void main(){} -- Derek Parnell Melbourne, Australia skype: derek.j.parnell
Mar 29 2008
prev sibling parent Mike Parker <aldacron71 yahoo.com> writes:
Koroskin Denis wrote:
 This won't compile under D 1.x:
 
 class SomeClass
 {
     version( D_Version2 )
     {
         invariant void someMethod()
         {
         }
     } else {
         const void someMethod()
         {
         }
     }
 }
 
 int main()
 {
     return 0;
 }
 
 
 Maybe 'version'ing should be less restrictive on syntax so that backward 
 compatibility could still be possible.
 Now I'm a little stuck with porting code from D2.012 to D1.028.
 
 Or should we just choose one version and stick with it?

What I'd like to see is a special case for language versions, such as with debug: debug { blah blah } So we could do something like: D_Version2 { blah blah } These blocks would only be parsed if the compiler conforms to that version of the spec or later.
Mar 29 2008