D1 -> D2

Sean Kelly sean at invisibleduck.org
Sun Nov 21 06:42:16 PST 2010


Walter Bright <newshound2 at digitalmars.com> wrote:
> Fawzi Mohamed wrote:
>>  From the discussion it seems that defining something like:
>>> version(D_Version2){
>>     template Const(T){
>>         alias const(T) Const;
>>     }
>>     template Immutable(T){
>>         alias immutable(T) Immutable;
>>     }
>>     immutable(T) Idup(T)(T val){
>>         return val.idup;
>>     }
>>     alias const(char)[] cstring;
>> } else {
>>     template Const(T){
>>         alias T Const;
>>     }
>>     template Immutable(T){
>>         alias T Immutable;
>>     }
>>     T Idup(T)(T val){
>>         return val.dup;
>>     }
>>     alias char[] string;
>>     alias char[] cstring;
>> }
>>> could help a lot
>> later one can simply replace Const! with const and Immutable! with >
> > immutable, Idup replacement is more complicated, but doable
> 
> The problem with this approach is it requires the D1 compiler to be
> able to parse D2 syntax, including recognizing all of D2's keywords.

Make them string mixins. I had druntime working on both D1 and D2 for a
while and did it with a mix of aliases, string mixins, and "in" for
const args. It worked, but ended up being worse than simply maintaining
two codebases.


More information about the Digitalmars-d mailing list