should I use 1.0 or 2.0?

Sean Kelly sean at invisibleduck.org
Tue Oct 28 17:23:32 PDT 2008


akcom wrote:
> For production applications, should I be using D 1.0 or D 2.0?

1.0.  But I suggest finding out the differences between 1.0 and 2.0 so 
you have some idea what you'll be in for if/when you decide to upgrade. 
  To ease the transition, there are some simple tricks that will help, 
such as labeling ostensibly const function parameters with 'in'.  For 
example:

     void fn( in char[] str ) {}

In D 1.0 this is equivalent to:

     void fn( char[] str ) {}

however, in D 2.0 this is equivalent to:

     void fn( const char[] str ) {}

Since string literals in D 2.0 are immutable, only immutable and 
constant variables may reference them.  So:

     fn( "hello" );

works in D 2.0 so long as fn() is defined as:

     fn( string str );
     fn( const char[] str );
     fn( invariant char[] str );

but not:

     fn( char[] str );

Most of the rest isn't worth the trouble, but I've found this to be a 
real time-saver for making code portable between D 1.0 and 2.0.


Sean


More information about the Digitalmars-d-learn mailing list