digitalmars.D.bugs - [Issue 11927] New: a good proposal
- d-bugmail puremagic.com (89/89) Jan 14 2014 https://d.puremagic.com/issues/show_bug.cgi?id=11927
- d-bugmail puremagic.com (9/9) Jan 14 2014 https://d.puremagic.com/issues/show_bug.cgi?id=11927
https://d.puremagic.com/issues/show_bug.cgi?id=11927 Summary: a good proposal Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: galaxylang gmail.com --- 1:>a normal dumb question is like this auto F() { } auto C(alias A)() { return A(); } auto B(A)() { return A(); } int main(string[] argv) { C!F(); B!F();//Error: template instance B!(F) does not match // template declaration B(A)() return 0; } this need change alias can accept syntax alias B=expression; i think C should change to B syntax,now we can talk about some enhancement 2:>lambda with template int main(string[] argv) { alias f=(x)=>x+1; f(1); f(1.0); return 0; } 3:so lambda function can pass to it auto more(F)() { return F(1)+1; } int main(string[] argv) { alias f=(x)=>x+2; more!(f)(); } 4:>template designed to compile time computing const value and types ,alias and pure function can compulate const , if a funtion only have function and types(without side effect values)just is a template to compulate types auto type(bool selector,A,B)() { alias type=selector?A:B; } auto isInt(T)() { alias isInt=(T is int); } alias Fun=type(int,F1,F2); //even more if we change syntax to auto type(bool selector,A,B) { alias type=selector?A:B; } auto isInt(T) { alias isInt=(T==int); } alias Fun=type(int,F1,F2); value and type campute now morge into one syntax,template keyword maybe would lost it's work 5:>Further,side effect value and type can in one function auto compute(T)(T i) { static if(T is int) alias compute=1; else alias compute=1.0/i; } -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 14 2014
https://d.puremagic.com/issues/show_bug.cgi?id=11927 --- 4:>template designed to compile time computing const value and types ,alias and pure function can compulate const , if a funtion only have types arguments(can have but without side effect values)just is a template to compulate types -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 14 2014