Conflict between function and template with the same name

Rene Zwanenburg via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jun 29 01:26:08 PDT 2014


On Sunday, 29 June 2014 at 07:16:10 UTC, Uranuz wrote:
> Is there any reason why function and template conflict. They 
> using different syntax to *call*. For template we have *!* but 
> for function we don't have it. So why compiler is not able to 
> see the difference?

I suspect this is by design. The following works, note the dot 
before the getByName function call:

import std.stdio;

string getByName(string name)
{
	return "smth";
}

template getByName(string name)
{
	enum getByName = .getByName(name);
}


void main()
{
	writeln(getByName!("name"));
}


More information about the Digitalmars-d-learn mailing list