www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Template alias parameter mixin import inference

reply "Simen Kjaeraas" <simen.kjaras gmail.com> writes:
The below code does not compile - it complains about writefln not being  
defined,
which of course it is not, in module b. Would it be possible to get import
inference for this sort of thing? I know it's currently as simple as  
placing
import statements within the "bar" template, but it seems to me this could  
have
been done in a more pleasant way.

//////////////////////

module a;
import std.stdio;

template bar()
{
	int i;
	
	void func()
	{
		writefln(i);
	}
}

void main()
{
	foo!(bar) a;
	a.func();
}

//////////////////////

module b;

struct foo(alias T)
{
	mixin T!();
}

//////////////////////

--Simen
Mar 31 2008
parent reply "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"Simen Kjaeraas" <simen.kjaras gmail.com> wrote in message 
news:op.t8vlwdfy1hx7vj spill04.lan...

 //////////////////////

 module a;
 import std.stdio;

public import std.stdio;
Mar 31 2008
parent "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"Jarrett Billingsley" <kb3ctd2 yahoo.com> wrote in message 
news:fsqn0b$i7h$1 digitalmars.com...
 "Simen Kjaeraas" <simen.kjaras gmail.com> wrote in message 
 news:op.t8vlwdfy1hx7vj spill04.lan...

 //////////////////////

 module a;
 import std.stdio;

public import std.stdio;

Ignore me. Thought I saw an "import a;" in module b. ._.
Mar 31 2008