digitalmars.D - is this a dmd bug ?
- Long Chang (15/15) Nov 24 2009 public interface Listener {
- Denis Koroskin (7/23) Nov 24 2009 Try removing a dot before print.
- Steven Schveighoffer (4/20) Nov 24 2009 It's the . before the print. It means "only look in the global scope".
- Long Chang (22/22) Nov 24 2009 how about this case:
- Steven Schveighoffer (9/33) Nov 24 2009 Try outer.toString(evt).
- Long Chang (8/8) Nov 24 2009 I use the d1 & tango trunk & dwt-win.
- Denis Koroskin (6/15) Nov 24 2009 Try using older version of Tango (before introducing Object.dispose()
- Steven Schveighoffer (31/40) Nov 24 2009 Hm... I've noticed that you can't just call outer, you have to use
- Long Chang (2/2) Nov 24 2009 this.outer also. work on d1.
public interface Listener { void handleEvent (int); } void main(){ void print(int evt){ } Listener listener = new class() Listener { public void handleEvent(int evt) { .print(evt); } }; } ----------------------------------------------------------------------------------- x.d(20): Error: undefined identifier module x.print x.d(20): Error: function expected before (), not module x.print of type void
Nov 24 2009
On Tue, 24 Nov 2009 14:55:44 +0300, Long Chang <changedalone gmail.com> wrote:public interface Listener { void handleEvent (int); } void main(){ void print(int evt){ } Listener listener = new class() Listener { public void handleEvent(int evt) { .print(evt); } }; } ----------------------------------------------------------------------------------- x.d(20): Error: undefined identifier module x.print x.d(20): Error: function expected before (), not module x.print of type voidTry removing a dot before print. As is, it searches for a print function at a global scope, fails to find one and shows an error. I'm not sure it is a proper behavior, though. Try creating a bugzilla report.
Nov 24 2009
On Tue, 24 Nov 2009 06:55:44 -0500, Long Chang <changedalone gmail.com> wrote:public interface Listener { void handleEvent (int); } void main(){ void print(int evt){ } Listener listener = new class() Listener { public void handleEvent(int evt) { .print(evt); } }; } ----------------------------------------------------------------------------------- x.d(20): Error: undefined identifier module x.print x.d(20): Error: function expected before (), not module x.print of type voidIt's the . before the print. It means "only look in the global scope". -Steve
Nov 24 2009
how about this case: public interface Listener { void handleEvent (int); } class Test{ this(){ Listener listener = new class() Listener { public void handleEvent(int evt) { toString(evt); } }; } void toString(int evt){ } } void main(){ } --------------------------------------- x.d(17): Error: function object.Object.toString () does not match parameter types (int) x.d(17): Error: expected 0 arguments, not 1 for non-variadic function type char[]()
Nov 24 2009
On Tue, 24 Nov 2009 07:38:51 -0500, Long Chang <changedalone gmail.com> wrote:how about this case: public interface Listener { void handleEvent (int); } class Test{ this(){ Listener listener = new class() Listener { public void handleEvent(int evt) { toString(evt); } }; } void toString(int evt){ } } void main(){ } --------------------------------------- x.d(17): Error: function object.Object.toString () does not match parameter types (int) x.d(17): Error: expected 0 arguments, not 1 for non-variadic function type char[]()Try outer.toString(evt). Note that the anonymous class inherits from Object, which defines toString as: char[] toString(); So the compiler thinks you are trying to call your anonymous class' toString, not the outer class' toString. -Steve
Nov 24 2009
I use the d1 & tango trunk & dwt-win. there is a new dispose method for Object, and Dwt-win already have a dispose width Event argument. I try it with outer, the error is : x.d(17): Error: undefined identifier outer x.d(17): Error: undefined identifier outer x.d(17): Error: no property 'toString' for type 'int' x.d(17): Error: function expected before (), not 1 of type int
Nov 24 2009
On Tue, 24 Nov 2009 16:09:28 +0300, Long Chang <changedalone gmail.com> wrote:I use the d1 & tango trunk & dwt-win. there is a new dispose method for Object, and Dwt-win already have a dispose width Event argument. I try it with outer, the error is : x.d(17): Error: undefined identifier outer x.d(17): Error: undefined identifier outer x.d(17): Error: no property 'toString' for type 'int' x.d(17): Error: function expected before (), not 1 of type intTry using older version of Tango (before introducing Object.dispose() method), or ask for help in digitalmars.DWT newsgroup. It's not a DMD but, it's just DWT is incompatible with Tango trunk at the moment (due to a breaking change in Tango).
Nov 24 2009
On Tue, 24 Nov 2009 08:09:28 -0500, Long Chang <changedalone gmail.com> wrote:I use the d1 & tango trunk & dwt-win. there is a new dispose method for Object, and Dwt-win already have a dispose width Event argument. I try it with outer, the error is : x.d(17): Error: undefined identifier outer x.d(17): Error: undefined identifier outer x.d(17): Error: no property 'toString' for type 'int' x.d(17): Error: function expected before (), not 1 of type intHm... I've noticed that you can't just call outer, you have to use this.outer. Does anyone know if this is expected behavior or a bug? Why would it be expected behavior? This code compiles for me and works on dmd 2.033 import std.stdio; public interface Listener { void handleEvent (int); } class Test{ Listener listener; this(){ listener = new class() Listener { public void handleEvent(int evt) { this.outer.toString(evt); } }; } void call() { listener.handleEvent(0); } void toString(int evt){ writefln("event is %d", evt); } } void main(){ (new Test()).call(); } -Steve
Nov 24 2009
this.outer also. work on d1. =C2=A0thank you guys.
Nov 24 2009