Bug 11927 – a good proposal

Status
RESOLVED
Resolution
INVALID
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-01-14T23:02:00Z
Last change time
2014-04-28T13:39:29Z
Assigned to
nobody
Creator
galaxylang

Comments

Comment #0 by galaxylang — 2014-01-14T23:02:34Z
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; }
Comment #1 by galaxylang — 2014-01-14T23:08:49Z
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
Comment #2 by andrej.mitrovich — 2014-04-28T09:28:13Z
I have to mark this as invalid because I can't comprehend these sentences. In the future please file each enhancement as a separate report, thanks. In the meantime, maybe someone else can decypher this and reopen it if necessary.
Comment #3 by blah38621 — 2014-04-28T13:17:53Z
I believe the first point is trying to suggest making what currently requires an explicit alias specifier on it, not require that alias keyword.
Comment #4 by gassa — 2014-04-28T13:39:29Z
The second one proposes to allow a lambda without types, as in: alias f=(x)=>x+1; So it can be used for different types: f(1); f(1.0);