D1 -> D2

Walter Bright newshound2 at digitalmars.com
Thu Nov 18 23:08:42 PST 2010


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.

> What is not so clear is how to cope with scope, because I have lot of 
> delegates around that will need it.
> For it a preprocessing step might really be the best thing, or someone 
> knows a smart way to cope with that?

Not sure what the issue is.


More information about the Digitalmars-d mailing list