On Fri, 19 Nov 2010 01:47:27 -0500, Fawzi Mohamed <[email protected]> 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

Reply via email to