www.digitalmars.com         C & C++   DMDScript  

D - DMD 0.77 bug: interface broken.

reply Burton Radons <loth users.sourceforge.net> writes:
Here's an example where calling a method on an interface breaks using 
DMD 0.77.

     interface I
     {
         void M ();
     }

     interface J : I
     {
         void N ();
     }

     class A : I
     {
         void M () { }
     }

     class B : A, J
     {
         void N () { }
     }

     void main ()
     {
         I f = new B ();

         f.M (); // Access violation.
     }

This code is valid; the function call should work.

Also, interface methods are not being treated like methods, as they
should be.  For example:

     interface I
     {
         void M ();
         void N ();
     }

     class A : I
     {
         // Doesn't work; it requires a body.
         abstract void M ();

         // Doesn't work; it's not considered part of the inheritance.
         override void N () { }
     }

These should both work.

Finally, this causes an access violation inside of the cast.  It should 
work.

     interface A
     {
         void ma ();
     }

     interface B
     {
         void mb ();
     }

     class C : A, B
     {
         void ma () { }
         void mb () { }
     }

     void main ()
     {
         A x = new C ();

         assert (cast (B) x);
     }

I should explain what my situation is, but I don't feel like going into 
it right now.
Jan 20 2004
next sibling parent John Reimer <jjreimer telus.net> writes:
Welcome back, Burton. Nice to hear from you.  Hope you're here to stay. :)
Jan 20 2004
prev sibling next sibling parent J Anderson <REMOVEanderson badmama.com.au> writes:
Welcome Back.

What are your plans with dig and the other cool software on your website?

-Anderson
Jan 20 2004
prev sibling next sibling parent "Walter" <walter digitalmars.com> writes:
"Burton Radons" <loth users.sourceforge.net> wrote in message
news:buku5a$21sm$1 digitaldaemon.com...
 Here's an example where calling a method on an interface breaks using
 DMD 0.77.
Thanks, I'll check it out. And welcome back! We've missed you here.
Jan 21 2004
prev sibling next sibling parent reply Burton Radons <loth users.sourceforge.net> writes:
Burton Radons wrote:
 Here's an example where calling a method on an interface breaks using 
 DMD 0.77.
 
     interface I
     {
         void M ();
     }
 
     interface J : I
     {
         void N ();
     }
 
     class A : I
     {
         void M () { }
     }
 
     class B : A, J
     {
         void N () { }
     }
 
     void main ()
     {
         I f = new B ();
 
         f.M (); // Access violation.
     }
 
 This code is valid; the function call should work.
 
 Also, interface methods are not being treated like methods, as they
 should be.  For example:
 
     interface I
     {
         void M ();
         void N ();
     }
 
     class A : I
     {
         // Doesn't work; it requires a body.
         abstract void M ();
 
         // Doesn't work; it's not considered part of the inheritance.
         override void N () { }
     }
 
 These should both work.
 
 Finally, this causes an access violation inside of the cast.  It should 
 work.
 
     interface A
     {
         void ma ();
     }
 
     interface B
     {
         void mb ();
     }
 
     class C : A, B
     {
         void ma () { }
         void mb () { }
     }
 
     void main ()
     {
         A x = new C ();
 
         assert (cast (B) x);
     }
 
 I should explain what my situation is, but I don't feel like going into 
 it right now.
These bugs remain in 0.81; I can't do anything with dig - or anything with interface abstraction - until they're fixed.
Mar 08 2004
next sibling parent reply "Tu Nam" <dreamweaver mail15.com> writes:
I fixed a bit about your sample.
import std.c.stdio;
    interface I
     {
         public void M ();
     }

     interface J : I
     {
         public void N ();
     }

     class A : I
     {
         public void M () {printf("Hello from A"); }
     }

     class B : A, J
     {
         public void N () { }
     }

     void main ()
     {
         J f = new B ();

         f.M ();
         getch();
     }
It's work .
BTW, I think that if you don't define "public" , initialy D will know it's
protected-package methods . I don't know much about OO with interface but
when I test your sample in Java , it don't work just like D . But if I treat
method of interface is public then it work . In Java if not have accessor so
it know method is package protected methods , and , sorry for my OO stupid ,
I don't know why it didn't work unless "public" .
Please could you have advise the case which you use "protected method" in
interface ???

"Burton Radons" <loth users.sourceforge.net> wrote in message
news:c2i4dg$lfs$1 digitaldaemon.com...
 Burton Radons wrote:
 Here's an example where calling a method on an interface breaks using
 DMD 0.77.

     interface I
     {
         void M ();
     }

     interface J : I
     {
         void N ();
     }

     class A : I
     {
         void M () { }
     }

     class B : A, J
     {
         void N () { }
     }

     void main ()
     {
         I f = new B ();

         f.M (); // Access violation.
     }

 This code is valid; the function call should work.

 Also, interface methods are not being treated like methods, as they
 should be.  For example:

     interface I
     {
         void M ();
         void N ();
     }

     class A : I
     {
         // Doesn't work; it requires a body.
         abstract void M ();

         // Doesn't work; it's not considered part of the inheritance.
         override void N () { }
     }

 These should both work.

 Finally, this causes an access violation inside of the cast.  It should
 work.

     interface A
     {
         void ma ();
     }

     interface B
     {
         void mb ();
     }

     class C : A, B
     {
         void ma () { }
         void mb () { }
     }

     void main ()
     {
         A x = new C ();

         assert (cast (B) x);
     }

 I should explain what my situation is, but I don't feel like going into
 it right now.
These bugs remain in 0.81; I can't do anything with dig - or anything with interface abstraction - until they're fixed.
Mar 08 2004
parent reply =?ISO-8859-1?Q?Julio_Jim=E9nez?= <jujibo inicia.es> writes:
Tu Nam wrote:
 I fixed a bit about your sample.
 import std.c.stdio;
     interface I
      {
          public void M ();
      }
 
      interface J : I
      {
          public void N ();
      }
 
      class A : I
      {
          public void M () {printf("Hello from A"); }
      }
 
      class B : A, J
      {
          public void N () { }
      }
 
      void main ()
      {
          J f = new B ();
 
          f.M ();
          getch();
      }
 It's work .
 BTW, I think that if you don't define "public" , initialy D will know it's
 protected-package methods . I don't know much about OO with interface but
Wrong, members are public by default (not protected).
 when I test your sample in Java , it don't work just like D . But if I treat
 method of interface is public then it work . In Java if not have accessor so
 it know method is package protected methods , and , sorry for my OO stupid ,
 I don't know why it didn't work unless "public" .
 Please could you have advise the case which you use "protected method" in
 interface ???
 
Well your code run fine, but is not the Burton Radons code..... you write: J f = new B (); but you must write following Burton's example: I f = new B (); that cause Access violation when f.M () is executed. Another thing,
Mar 09 2004
parent "Tu Nam" <dreamweaver mail15.com> writes:
I'm terrible sorry  , perhap I overdosed ;(((

"Julio Jiménez" <jujibo inicia.es> wrote in message
news:c2kiiv$1t40$1 digitaldaemon.com...
 Tu Nam wrote:
 I fixed a bit about your sample.
 import std.c.stdio;
     interface I
      {
          public void M ();
      }

      interface J : I
      {
          public void N ();
      }

      class A : I
      {
          public void M () {printf("Hello from A"); }
      }

      class B : A, J
      {
          public void N () { }
      }

      void main ()
      {
          J f = new B ();

          f.M ();
          getch();
      }
 It's work .
 BTW, I think that if you don't define "public" , initialy D will know
it's
 protected-package methods . I don't know much about OO with interface
but
 Wrong, members are public by default (not protected).

 when I test your sample in Java , it don't work just like D . But if I
treat
 method of interface is public then it work . In Java if not have
accessor so
 it know method is package protected methods , and , sorry for my OO
stupid ,
 I don't know why it didn't work unless "public" .
 Please could you have advise the case which you use "protected method"
in
 interface ???
Well your code run fine, but is not the Burton Radons code..... you write: J f = new B (); but you must write following Burton's example: I f = new B (); that cause Access violation when f.M () is executed. Another thing,
Mar 09 2004
prev sibling parent "Kris" <someidiot earthlink.dot.dot.dot.net> writes:
I, too, have run aground on each of these issues; they are still present in
0.82, and are giving me grief with Dsc. Access violations of any kind should
ideally be fixed asap, but these interface-related ones seem to persist
longer than one might hope for.

Maybe we should petition Walter <g>


"Burton Radons" <loth users.sourceforge.net> wrote in message
news:c2i4dg$lfs$1 digitaldaemon.com...
 Burton Radons wrote:
 Here's an example where calling a method on an interface breaks using
 DMD 0.77.

     interface I
     {
         void M ();
     }

     interface J : I
     {
         void N ();
     }

     class A : I
     {
         void M () { }
     }

     class B : A, J
     {
         void N () { }
     }

     void main ()
     {
         I f = new B ();

         f.M (); // Access violation.
     }

 This code is valid; the function call should work.

 Also, interface methods are not being treated like methods, as they
 should be.  For example:

     interface I
     {
         void M ();
         void N ();
     }

     class A : I
     {
         // Doesn't work; it requires a body.
         abstract void M ();

         // Doesn't work; it's not considered part of the inheritance.
         override void N () { }
     }

 These should both work.

 Finally, this causes an access violation inside of the cast.  It should
 work.

     interface A
     {
         void ma ();
     }

     interface B
     {
         void mb ();
     }

     class C : A, B
     {
         void ma () { }
         void mb () { }
     }

     void main ()
     {
         A x = new C ();

         assert (cast (B) x);
     }

 I should explain what my situation is, but I don't feel like going into
 it right now.
These bugs remain in 0.81; I can't do anything with dig - or anything with interface abstraction - until they're fixed.
Mar 31 2004
prev sibling parent "Walter" <newshound digitalmars.com> writes:
"Burton Radons" <loth users.sourceforge.net> wrote in message
news:buku5a$21sm$1 digitaldaemon.com...
 Here's an example where calling a method on an interface breaks using
 DMD 0.77.

      interface I
      {
          void M ();
      }

      interface J : I
      {
          void N ();
      }

      class A : I
      {
          void M () { }
      }

      class B : A, J
      {
          void N () { }
      }

      void main ()
      {
          I f = new B ();

          f.M (); // Access violation.
      }

 This code is valid; the function call should work.
Fixed in next update.
 Also, interface methods are not being treated like methods, as they
 should be.  For example:

      interface I
      {
          void M ();
          void N ();
      }

      class A : I
      {
          // Doesn't work; it requires a body.
          abstract void M ();
Already fixed.
          // Doesn't work; it's not considered part of the inheritance.
          override void N () { }
This doesn't compile, and I don't think it should.
      }

 These should both work.

 Finally, this causes an access violation inside of the cast.  It should
 work.

      interface A
      {
          void ma ();
      }

      interface B
      {
          void mb ();
      }

      class C : A, B
      {
          void ma () { }
          void mb () { }
      }

      void main ()
      {
          A x = new C ();

          assert (cast (B) x);
      }
This currently works.
May 25 2004