www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9365] New: Allow partially specified template aliases

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

           Summary: Allow partially specified template aliases
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: peter.alexander.au gmail.com



12:50:45 PST ---
It would be helpful if it were possible to alias partially specified templates.
An example:

void foo(A, B)() {}

alias foo!int fooInt;

Currently this fails with "Error: template instance foo!(int) foo!(int) does
not match template declaration foo(A, B)()".

However, if you write foo as:

template foo(A)
{
    void foo(B)() {}
}

Then it works.

This would be useful because it would allow you to write things like:

alias equalRoR = equal!equal;

instead of having to write:

alias equalRoR = binaryFun!((a, b) => equal!equal(a, b));

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 21 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9365


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com



13:15:33 PST ---
This can be implemented in the library, the last thing you want is for
templates being partially instantiated when you pass too few arguments instead
of getting an error.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 21 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9365




15:11:58 PST ---

 This can be implemented in the library, the last thing you want is for
 templates being partially instantiated when you pass too few arguments instead
 of getting an error.
There will be no partial instantiation (what it that anyway?) What I'm asking for is a rewrite from: alias A = B!(x, y); to alias A = ((args...) => B!(x, y)(args)); // if this was valid syntax when B has more than 2 non-default template parameters. The rest are determined using type deduction when A is invoked. This is frustrating: void foo(A, B)(A a, B b) {} foo(1, 2); // OK foo!(int)(1, 2); // OK foo!(int, int)(1, 2); // OK alias X = foo; // OK alias Y = foo!(int); // ERROR alias Z = foo!(int, int); // OK -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 21 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9365


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies gmail.com



Something like

alias A(T) = B!(x, T);

Is more likely and more flexible.

Expanding to:

template A(T)
{
    alias A B!(x, T)
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 21 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9365




23:35:09 PDT ---

 Something like
 
 alias A(T) = B!(x, T);
 
 Is more likely and more flexible.
See my use case, with your suggestions, this wouldn't work: alias equalRoR = equal!equal; An alternative suggestion, is to change how function templates are expanded. Currently we have: void foo(A, B)(A a, B b) expanding to template foo(A, B) { void foo(A a, B b); } If instead, it expanded to: template foo(A) { template foo(B) { void foo(A a, B b); } } Then foo!int becomes a valid, alias-able symbol, which would solve the problem as well. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 09 2013