Thread overview
Mixining templates having functions with the same name
Apr 02, 2006
Victor Nakoryakov
Apr 02, 2006
John Demme
Apr 04, 2006
Victor Nakoryakov
Apr 04, 2006
Bruno Medeiros
Apr 07, 2006
Victor Nakoryakov
Apr 08, 2006
Bruno Medeiros
April 02, 2006
Hello,

Consider snipet:

template T1()
{
	void myproperty(real x) // line X
	{
		...
	}
}

template T2()
{
	real myproperty() // line Y
	{
		return ...;
	}
}

class C(alias M1, alias M2)
{
	mixin M1!();
	mixin M2!();

	...
}

...
auto c = new C!(T1, T2)
...

Compilation of course gives an error: 'myproperty on line X conflicts with myproperty on line Y', this is expected dmd behaviour.

But in this case I know what I do. So who know elegant solution do disambigue instanciation?

-- 
Victor (aka nail) Nakoryakov
nail-mail<at>mail<dot>ru

Krasnoznamensk, Moscow, Russia
April 02, 2006
Victor Nakoryakov wrote:

> Hello,
> 
> Consider snipet:
> 
> template T1()
> {
> void myproperty(real x) // line X
> {
> ...
> }
> }
> 
> template T2()
> {
> real myproperty() // line Y
> {
> return ...;
> }
> }
> 
> class C(alias M1, alias M2)
> {
> mixin M1!();
> mixin M2!();
> 
> ...
> }
> 
> ...
> auto c = new C!(T1, T2)
> ...
> 
> Compilation of course gives an error: 'myproperty on line X conflicts with myproperty on line Y', this is expected dmd behaviour.
> 
> But in this case I know what I do. So who know elegant solution do disambigue instanciation?
> 
template T1()
{
        void myproperty(real x) // line X
        {

        }
}

template T2()
{
        real myproperty() // line Y
        {
                return 5;
        }
}

class C(alias M1, alias M2)
{
        mixin M1!();
        mixin M2!();

}

void main()
{
        auto c = new C!(T1,T2);
}

The above code compiles, links, and runs fine with DMD 0.150 on Linux.

~John Demme
April 04, 2006
John Demme wrote:
> The above code compiles, links, and runs fine with DMD 0.150 on Linux.

Ooops, forgot one line... following code doesn't compile:

template T1()
{
        void myproperty(real x) // line X
        {

        }
}

template T2()
{
        real myproperty() // line Y
        {
                return 5;
        }
}

class C(alias M1, alias M2)
{
        mixin M1!();
        mixin M2!();

}

void main()
{
        auto c = new C!(T1,T2);
        c.myproperty = 0;
}

dmd ../test
..\test.d(8): function test.C!(T1,T2).C.mixin M1!();
.myproperty conflicts with test.C!(T1,T2).C.mixin M2!();
.myproperty at ..\test.d(16)

-- 
Victor (aka nail) Nakoryakov
nail-mail<at>mail<dot>ru

Krasnoznamensk, Moscow, Russia
April 04, 2006
Victor Nakoryakov wrote:
> John Demme wrote:
>> The above code compiles, links, and runs fine with DMD 0.150 on Linux.
> 
> Ooops, forgot one line... following code doesn't compile:
> 
> template T1()
> {
>         void myproperty(real x) // line X
>         {
> 
>         }
> }
> 
> template T2()
> {
>         real myproperty() // line Y
>         {
>                 return 5;
>         }
> }
> 
> class C(alias M1, alias M2)
> {
>         mixin M1!();
>         mixin M2!();
> 
> }
> 
> void main()
> {
>         auto c = new C!(T1,T2);
>         c.myproperty = 0;
> }
> 
> dmd ../test
> ...\test.d(8): function test.C!(T1,T2).C.mixin M1!();
> ..myproperty conflicts with test.C!(T1,T2).C.mixin M2!();
> ..myproperty at ..\test.d(16)
> 

Hum, seems like a bug to me, do fill a report:
http://d.puremagic.com/bugzilla

-- 
Bruno Medeiros - CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
April 07, 2006
Sorry for delay, I'm totally forgot about my post :)

Bruno Medeiros wrote:
> 
> Hum, seems like a bug to me, do fill a report:
> http://d.puremagic.com/bugzilla
> 

I think it isn't. The same error you get on attempt to use some identifier that found in two modules that are imported. And this is expected behaviour described in docs. My case is the same situation, but I search a way to cheat the compiler.


-- 
Victor (aka nail) Nakoryakov
nail-mail<at>mail<dot>ru

Krasnoznamensk, Moscow, Russia
April 08, 2006
Victor Nakoryakov wrote:
> Sorry for delay, I'm totally forgot about my post :)
> 
> Bruno Medeiros wrote:
>>
>> Hum, seems like a bug to me, do fill a report:
>> http://d.puremagic.com/bugzilla
>>
> 
> I think it isn't. The same error you get on attempt to use some identifier that found in two modules that are imported. And this is expected behaviour described in docs. My case is the same situation, but I search a way to cheat the compiler.
> 
> 
Yes, it seems like a similar error, yet I think mixins should allow for function overloading. I've submitted a bug report: http://d.puremagic.com/bugzilla/show_bug.cgi?id=96
Let's see how it turns out.

-- 
Bruno Medeiros - CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D