[Issue 1807] ENHANCEMENT: Let IFTI "see through" templates to simple aliases
https://issues.dlang.org/show_bug.cgi?id=1807 kdevel changed: What|Removed |Added CC||kde...@vogtner.de --
[Issue 1807] ENHANCEMENT: Let IFTI "see through" templates to simple aliases
https://issues.dlang.org/show_bug.cgi?id=1807 FeepingCreature changed: What|Removed |Added CC||default_357-l...@yahoo.de --- Comment #12 from FeepingCreature --- *** Issue 23798 has been marked as a duplicate of this issue. *** --
[Issue 1807] ENHANCEMENT: Let IFTI "see through" templates to simple aliases
https://issues.dlang.org/show_bug.cgi?id=1807 Iain Buclaw changed: What|Removed |Added Priority|P2 |P4 --
[Issue 1807] ENHANCEMENT: Let IFTI "see through" templates to simple aliases
https://issues.dlang.org/show_bug.cgi?id=1807 --- Comment #11 from John Hall --- Creating a new type with an alias this'ed parameter is similar conceptually to a template alias. The new type is implicitly convertible to the target of the alias this and can be used wherever that original type was used. However, since it is a separate type, it can't called called where the alias is used. ```d struct TemplateType(T) {} //alias TemplateAlias(T) = TemplateType!T; struct TemplateAlias(T) { TemplateType!T x; alias x this; } void templateFunction(T)(TemplateType!T arg) {} void templateAliasFunction(T)(TemplateAlias!T arg) {} void main() { TemplateType!int inst; TemplateAlias!int ainst; templateFunction(inst); templateFunction(ainst); templateAliasFunction(inst); //doesn't compile templateAliasFunction(ainst); } ``` Perhaps what is needed is some kind of mechanism like alias this...not in the sense of implicit conversion but in terms the programmer having the tools to tell the compiler what to do. The idea would be that your template alias would include an additional template (with some rudimentary sketch below), call it `opResolveAlias`, that would let the compiler know the relationships going in reverse (so instead of from the alias to the alias target, this would be going from the alias target to the alias). The compiler could then make use of that information to make sure the function call can properly occur (with type inference as needed). So for instance, if you have a function that accepts a `TemplateAlias!T` parameter, but pass in a `TemplateType!int` parameter, then currently the compiler doesn't look through the `TemplateAlias!T` to see that `TemplateType!int` is the same. However, if the compiler knows that a `TemplateType!int` is the same as `TemplateAlias!int`, then it would be better able to proceed. ```d template TemplateAlias(T) { alias TemplateAlias = TemplateType!T; template opResolveAlias(alias U) if(is(U == TemplateType!V, V)) { alias opResolveAlias = TemplateAlias!V; } } ``` For simple cases like this, the compiler could generate its own `opResolveAlias`, but in the more general case it would be up to the user to provide it if it is important to them. Issue 16486 has an example of a more complicated template alias [1] that should still be able to have this approach applied: ```d template TestAlias(T) { static if (is(T == float)) alias TestAlias = TestType!int; else alias TestAlias = string; // new part: template opResolveAlias(alias U) { static if (is(U == TestType!int)) { alias opResolveAlias = TestAlias!float; } else static if (is(U == string)) { alias opResolveAlias = TestAlias!int; //could put anything there that's not float...not the most elegant } } } ``` [1] https://issues.dlang.org/show_bug.cgi?id=16486#c1 --
[Issue 1807] ENHANCEMENT: Let IFTI "see through" templates to simple aliases
https://issues.dlang.org/show_bug.cgi?id=1807 John Hall changed: What|Removed |Added CC||john.michael.h...@gmail.com --- Comment #10 from John Hall --- (In reply to Walter Bright from comment #9) > Proposed DIP: > > https://github.com/dlang/DIPs/blob/master/DIPs/other/DIP1023.md > > Proposed Implementation: > > https://github.com/dlang/dmd/pull/9778 DIP 1023 has been postponed. --
[Issue 1807] ENHANCEMENT: Let IFTI "see through" templates to simple aliases
https://issues.dlang.org/show_bug.cgi?id=1807 ag0aep6g changed: What|Removed |Added CC||ag0ae...@gmail.com Summary|Wad3|ENHANCEMENT: Let IFTI "see ||through" templates to ||simple aliases --
[Issue 1807] ENHANCEMENT: Let IFTI "see through" templates to simple aliases
https://issues.dlang.org/show_bug.cgi?id=1807 --- Comment #9 from Walter Bright --- Proposed DIP: https://github.com/dlang/DIPs/blob/master/DIPs/other/DIP1023.md Proposed Implementation: https://github.com/dlang/dmd/pull/9778 --
[Issue 1807] ENHANCEMENT: Let IFTI "see through" templates to simple aliases
https://issues.dlang.org/show_bug.cgi?id=1807 Walter Bright changed: What|Removed |Added See Also||https://issues.dlang.org/sh ||ow_bug.cgi?id=1653, ||https://issues.dlang.org/sh ||ow_bug.cgi?id=1942, ||https://issues.dlang.org/sh ||ow_bug.cgi?id=3904, ||https://issues.dlang.org/sh ||ow_bug.cgi?id=7529, ||https://issues.dlang.org/sh ||ow_bug.cgi?id=10884, ||https://issues.dlang.org/sh ||ow_bug.cgi?id=16465, ||https://issues.dlang.org/sh ||ow_bug.cgi?id=16486 --
[Issue 1807] ENHANCEMENT: Let IFTI "see through" templates to simple aliases
https://issues.dlang.org/show_bug.cgi?id=1807 --- Comment #8 from RazvanN --- *** Issue 1942 has been marked as a duplicate of this issue. *** --
[Issue 1807] ENHANCEMENT: Let IFTI "see through" templates to simple aliases
https://issues.dlang.org/show_bug.cgi?id=1807 anonymous4 changed: What|Removed |Added Keywords||spec Hardware|x86 |All OS|Linux |All --
[Issue 1807] ENHANCEMENT: Let IFTI "see through" templates to simple aliases
https://issues.dlang.org/show_bug.cgi?id=1807 --- Comment #7 from ag0aep6g --- *** Issue 10884 has been marked as a duplicate of this issue. *** --
[Issue 1807] ENHANCEMENT: Let IFTI "see through" templates to simple aliases
http://d.puremagic.com/issues/show_bug.cgi?id=1807 d...@dawgfoto.de changed: What|Removed |Added CC||d...@dawgfoto.de --- Comment #6 from d...@dawgfoto.de 2012-02-18 09:40:40 PST --- One issue with this is that treating certain kinds of templates different that others will make it very difficult to understand why matching might fail. If we want to have alias templates to behave different than plain templates they should have a language construct that enforces the limitations and resembles struct templates. alias(T) void delegate(T*) wrap; expands to: template wrap(T) { alias void delegate(T*) wrap; } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 1807] ENHANCEMENT: Let IFTI "see through" templates to simple aliases
http://d.puremagic.com/issues/show_bug.cgi?id=1807 timon.g...@gmx.ch changed: What|Removed |Added CC||kyfo...@gmail.com --- Comment #5 from timon.g...@gmx.ch 2012-02-17 14:20:38 PST --- *** Issue 7529 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 1807] ENHANCEMENT: Let IFTI "see through" templates to simple aliases
http://d.puremagic.com/issues/show_bug.cgi?id=1807 Steven Schveighoffer changed: What|Removed |Added CC||bearophile_h...@eml.cc --- Comment #4 from Steven Schveighoffer 2010-03-09 04:15:46 PST --- *** Issue 3904 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 1807] ENHANCEMENT: Let IFTI "see through" templates to simple aliases
http://d.puremagic.com/issues/show_bug.cgi?id=1807 [EMAIL PROTECTED] changed: What|Removed |Added CC||[EMAIL PROTECTED] --- Comment #3 from [EMAIL PROTECTED] 2008-11-14 14:00 --- *** Bug 1653 has been marked as a duplicate of this bug. *** --