What am I doing wrong here?

Martin martinbbjerregaard at gmail.com
Sun Oct 14 05:28:10 PDT 2012


Hey everyone, I'm new to D so bare with me please. I've been 
trying to figure out what's up with the strange forward refernce 
errors the compiler (DMD 2.060) is giving me. Here's a code 
snippet that's generating a forward reference error:

public class AliasTestClass(alias func)
{
	
	static assert(__traits(isStaticFunction, func));
		
}

public class TestClass
{
	
	private AliasTestClass!(randomFunction) test; // <-----
		
	public static void randomFunction()
	{
	}
	
}

The strange part about it is that if I surround the 
randomFunction parameter with another pair of paranthesis like so

private AliasTestClass!((randomFunction)) test;

It works just fine. If I don't, however, I get a forward 
reference error:
"Error: template instance main.AliasTestClass!(randomFunction) 
forward reference of randomFunction"

Am I doing anything wrong or is this some kind of bug?


More information about the Digitalmars-d-learn mailing list