www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - typeof(this).meber() >>Virtual.d(11): no identifier for declarator (DMD 0.91 linux)

reply Ant <duitoolkit yahoo.ca> writes:
on DMD 0.91 linux version:

class A
{
	void a()
	{
		printf("A.a\n");
	}
	
	void b()
	{
		typeof(this).a();
	}
}

class B : A
{
	void a()
	{
		printf("B.a\n");
	}
	
}
	
int main(char[][] args)
{
	B b = new B();
	
	b.b();
	
 	return 0;
}

$ dmd Virtual.d -I~/dmd/src/phobos
Virtual.d(11): no identifier for declarator


maybe I didn't get(?)
is it suppose to compile like that?

Ant
May 28 2004
parent reply "Walter" <newshound digitalmars.com> writes:
Ak. The problem is it thinks it's a declaration. Try 0,typeof(this).a();

"Ant" <duitoolkit yahoo.ca> wrote in message
news:pan.2004.05.29.01.58.58.964162 yahoo.ca...
 on DMD 0.91 linux version:

 class A
 {
 void a()
 {
 printf("A.a\n");
 }

 void b()
 {
 typeof(this).a();
 }
 }

 class B : A
 {
 void a()
 {
 printf("B.a\n");
 }

 }

 int main(char[][] args)
 {
 B b = new B();

 b.b();

   return 0;
 }

 $ dmd Virtual.d -I~/dmd/src/phobos
 Virtual.d(11): no identifier for declarator


 maybe I didn't get(?)
 is it suppose to compile like that?

 Ant
May 28 2004
parent Ant <duitoolkit yahoo.ca> writes:
On Fri, 28 May 2004 22:56:22 -0700, Walter wrote:

 Ak. The problem is it thinks it's a declaration. Try 0,typeof(this).a();
 
yes, it worked (but I guess you'll correct it). I changed it to: interface I { void a(); void b(); } class A : I { void a() { printf("A.a\n"); } void b() { 0,typeof(this).a(); a(); } } class B : A { void a() { printf("B.a\n"); } } int main(char[][] args) { I b = new B(); b.b(); return 0; } it prints: A.a B.a I guess it's the expected result (as much as it displeases me). but it shows another problem with the sintax, (This new problem is not unrelated with the constructores being named "this". There is a big confusion on D with the "this" keyword) "this" should represent the object not something else. on the line "0,typeof(this).a();", "this" clearly does not represent the object. the sintax is not good. the idea is not good. Ant
May 29 2004