Infer function template parameters
jerro
a at a.com
Fri Sep 21 11:48:02 PDT 2012
> Although I like it, I wonder if it works in D's context free
> grammar. Timon probably would know best...
>
> I came up with this code, which compiles today:
>
> import std.stdio;
> alias int x;
>
> void foo(x) {}
>
> void foo2(string x) {writeln(x);}
>
> void main()
> {
> foo(1);
> foo2("hello");
> }
>
> Under your proposal, if we shorten foo2 to foo2(x), what
> happens? Does it become just like foo? Or does it turn into a
> template? Or is it an error?
I don't see any way the proposed syntax could work either. We
could have this, though:
auto min(auto a, auto b)
{
return a < b;
}
But I don't think this feature is worth changing the language
anyway.
More information about the Digitalmars-d
mailing list