www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5166] New: about D's template enhancement

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5166

           Summary: about D's template enhancement
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: galaxylang gmail.com


--- Comment #0 from galaxylang <galaxylang gmail.com> 2010-11-04 22:00:42 PDT
---
//i am a D's pursuer,this i think some about D's template,hope you can take a
look at it

//assume !    is right associate template apply operator,
//assume !! is template concat operator
//assume is(T:alias) traits function support

//i will show them as some sample

void twostepinstance()
{
    //this is also a sample show depends resolve
    struct    A(U)
    {
        //step1: U is nothing,allowed
        //step2: U is B!A

        //for class A{},A seem as a symbol,but also can be seen as a type
        //for class B(T){},B just a symbol
        //is alias means it's a symbol        

        static if(is(U==alias))//step2,apply int,U!int=B!A!int    
            auto opCall(){return U!int();}
    }
    struct B(U)
    {
    }
    alias    B!A!B!A    BABA;//because right associate,B!A!B!A==B!(A!(B!A)))

    static if(is(BABA D==alias)
    {
        //D bind to sybmol B
    }
    BABA    value;//BABA can be instance because A!()    allowed
}
void listcompendium()
{
    template ConcreteAble(L)
    {
        ...
    }
    //template calac as functions
    template Foreach_reverse(L)
    {
        static popFront()
        {
            alias    Foreach_reverse!(L[0..$-1])    Foreach_reverse;
        }
        static top()
        {
            return    L[$-1];
        }
        static empty()
        {
            return L.length==0;
        }
    }
    template Reverse(L)
    {
        alias    Foreach_reverse!(L)    Reverse;
    }
    struct    Struct(Any)
    {
        ConcreteAble!Any    _;
    }

    //anyway,V is a list,for simply V==V[0] if V.length==1,compatible with D2
    //needn't (...) comprehensive indication,just bind list to identity V
    //V away can be concat by !! operator.example see bellow.
    class    A(V)
    {

    }
    class    B(U,V):A(V)
    {
        alias    Struct!(U[0]!(Reverse!V))Revert;
    }
    //1.pay attention to C and typeof(C),the first can't be direct instanced
    //2.[] as compendious of list,some time can be thrift
    class    C(V):B!([C,typeof(this)],V)
    {
        auto    opCall()
        {
            return    Revert();//why this syntax is not acceptable in D?
        }    
    }

    alias    C!(int,long)        ConcreteC;//same as C!([int,long]),[] was
thrift because C has only one templateparam T
                                          //otherwise report confusion error

    alias    typeof(ConcreteC)    OpResult;//Strcut!([long,int])
    struct    ImplicitCastable
    {
        long    l;
        int        i;
    }
    //implicit    copy struct if have same tuple
    ImplicitCastable    r=(new ConcreateC())();

}
void    concatinstance
{
    struct    A(U)
    {
        U    value;
    }
    alias    A!int    V1;
    static if(version==VERSION2)
    {
        alias    V1!!int    V2;

        V2    v2;//type of A!([int,int])
        V1    v1;//type of A!([int]),list predigest
        v2=v1;//warning but can copy
        v1=v2;//error
    }

    //i think do it like this will reduce and simplify the template function if
provide,but not sure
    template Concat(L)
    {
        alias L Concat;
    }
    alias    Concat!int    VI;    //[int]==int
    alias    VI!!long    VIL;//[int,long]
}
//I am care about D for a long time,i am sure D will be became the best system
program in the future,
//but also i would complain about the development mehtod.
//1.I think a fast prototype needed when D2 start,
//and use c is a bad choice,this recall me the development of perl,i am not
like perl,but perl6's
//delelopment method is worthy,we use rapidity prototype language a front and
gcc as it's end should be better.
//Even more,graph rewirte maybe the best choice,but i am not sure. C is not a
good language 
//for quikly convergent bugs when requirement has not stable.
//2.I surguest import more functional style syntax and the stdlib should
reorgnizeation or delay sometime .
//3.And D for mobile is also needed,i think the mobile network will be the
futrue.


//I am now prepare for graduate examine,so i am not have enough time on
net.Beforetime,i 
//have suggest for the concat instance syntax because i had got a good
ideal,but now i forgot it because
//poor of english and too many enlish worlds need me to remember :-: ,so i got
this one 
//make up the number,not a good example.I only think a litte about template
because i am form cpp,which
//is surely a bad language :) for develop large program,and should be abondon
right now.
//Some time we need goto higher,then we think it,then the inspiration flash.
//For d hasn't too many people use it,change will influence fewer people,we
need make it perfect then the pursuer come.
//I now study quantum mechanics,i found the itself-contained,tangent and
presentational in quantum mechanics is same as
//our pursuance in develop progam and progam language, but i havn't more time
think about it right now.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 04 2010
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5166


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |andrej.mitrovich gmail.com
         Resolution|                            |INVALID


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2012-12-09
09:03:06 PST ---
It's almost impossible to decypher what is wanted here. I suggest you use the D
forums (http://forum.dlang.org/) to discuss these involved enhancements.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 09 2012