D1 -> D2
    Steven Schveighoffer 
    schveiguy at yahoo.com
       
    Fri Nov 19 05:01:27 PST 2010
    
    
  
On Fri, 19 Nov 2010 01:47:27 -0500, Fawzi Mohamed <fawzi at gmx.ch> 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
> 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?
BTW, this doesn't work as well as you would think.  The problem is with  
IFTI.
For example, IFTI can handle this:
void foo(T)(const(T) arg)
but cannot handle this:
void foo(T)(Const!(T) arg)
It was one of the things we were trying to do in Tango for D2, we had  
aliases for const/immutable/mutable strings templated on character type,  
but all of Tango's IFTI usage failed to compile.  It's a really old bug I  
filed:
http://d.puremagic.com/issues/show_bug.cgi?id=1653
which was superseded by:
http://d.puremagic.com/issues/show_bug.cgi?id=1807
-Steve
    
    
More information about the Digitalmars-d
mailing list