Smooth transition to D2 for Tango users?

Sean Kelly sean at invisibleduck.org
Mon Sep 22 18:10:51 PDT 2008


Sergey Gromov wrote:
> Steven Schveighoffer <schveiguy at yahoo.com> wrote:
>> oops, D1 doesn't support that type of enum ;)
> 
> I think you've got the idea. The code
> 
> version (D_Version2)
> {
>   mixin("some very specific code");
> }
> 
> works in any version of D, current or future.

String mixins don't work directly for everything though.  If you want to 
change a return value from non-const to const, for example, you need to 
make an alias for it using a versioned string mixin and then use the 
alias in the function declaration.  And then there are things like this:

// D1
const x = "hello";

// D2
enum x = "hello";

With string mixins you end up having to duplicate the entire line, and 
this can be a disaster if you're trying to maintain large header files 
with tons of declarations.

Finally, I think the version(D_Version2) idea is backwards.  It should 
be version(D_Version1).  The current method isn't forwards-compatible, 
so all the code with these version statements in it will break when we 
get D version 3.


Sean



More information about the Digitalmars-d mailing list