Template functions, can we make it more simple?
Tommi
tommitissari at hotmail.com
Fri Aug 2 14:09:47 PDT 2013
On Friday, 2 August 2013 at 20:50:00 UTC, SteveGuo wrote:
> auto Add(A, B)(A a, B b); // Yes, this is the template function
> declaration of D manner
>
> But I mean if the syntax can be more simple?
>
> auto Add(A, B)(A a, B b); // type A, B appears twice
>
> // Can we just make it more simple?
> auto Add(a, b)
> {
> }
I think it could get pretty confusing. I.e.:
module foo;
struct a { }
struct b { }
----
module bar;
import foo;
auto Add(a, b) { } // [1]
----
[1] Here the unsuspecting programmer thinks he's writing a
template function, not knowing that one module he's importing
actually specifies 'a' and 'b' as types, which makes his Add a
regular function taking unnamed variables of types 'a' and 'b'.
More information about the Digitalmars-d
mailing list