digitalmars.D.bugs - [Issue 6394] New: template type constraints embedded in the function parameters.
- d-bugmail puremagic.com (17/17) Jul 28 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6394
- d-bugmail puremagic.com (34/34) Jul 28 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6394
http://d.puremagic.com/issues/show_bug.cgi?id=6394 Summary: template type constraints embedded in the function parameters. Product: D Version: D2 Platform: Other OS/Version: Windows Status: NEW Severity: enhancement Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: gor boloneum.com --- Comment #0 from Gor Gyolchanyan <gor boloneum.com> 2011-07-28 08:43:43 PDT --- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 28 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6394 --- Comment #1 from Gor Gyolchanyan <gor boloneum.com> 2011-07-28 08:49:18 PDT --- Given the code: --------------- template SomeStruct(Type) { static if(is(Type == struct) || is(Type == class) || is(Type == interface)) enum StaticStruct = true; else enum StaticStruct = false; } --------------- I suggest a syntax sugar for template functions: --------------- void f(SomeStruct s) { } --------------- be transformed into: --------------- void f(Type_0_)(Type_0_ s) if(SomeStruct!Type_0_) { } --------------- IF the given type isn't a valid type, it'll search for a template, that takes a single type and evaluates to a bool and transform the function if the type name is such a template. this would greatly increase the readability of generic functions and allow to avoid creating enormous template constraints, as well as provide a better diagnostics, like "the type T is not a SomeStruct" or something like that. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 28 2011