Interface support?

1 view
Skip to first unread message

Sam Hu

unread,
Aug 3, 2008, 11:11:17 PM8/3/08
to eC Programming Language
Hi there,

I am absolutely a newbie and not an expert on computer programming,but
I do love the world of binary system.Just wanna know whether it is
possible for eC to implement the interface.

Thanks and best regards,
Sam

Jerome St-Louis

unread,
Aug 4, 2008, 4:49:23 AM8/4/08
to ec-programm...@googlegroups.com
Hi Sam,

I'm not sure exactly what you're asking...

Ecere includes a Graphical User Interface engine to build user interfaces, which you can write in eC...

Is this what you want to know? Please give me more details of what you'd like to do.

Regards,

Jerome

Sam Hu

unread,
Aug 4, 2008, 9:24:08 PM8/4/08
to eC Programming Language
Hi Jerome,

It seems that I replied to your mailbox,sorry!

What I mean is that ,say,in C# and other OOP laguage,there is a key
word like Interface and Delegate/Event...,For Interface,act as a
bridge to implement multi-inheritance,
For example:
Interface IRun
{
int Speed();
}
class Car:IRun
{
int Speed();
//Other member;
}
class Dog:IRun
{
int Speed();
//Other member;
}
Not sure whether it is clear.

Regards,
Sam

Jerome St-Louis

unread,
Aug 4, 2008, 10:27:36 PM8/4/08
to ec-programm...@googlegroups.com, SamHu...@gmail.com
Hi Sam,

Sorry I misunderstood your question :)

eC currently doesn't have an interface keyword, but I have been contemplating including it in a future version of the language...

eC however currently has some special experimental features which does something somewhat similar, which we might want to improve.

Here's some sample code demonstrating some of it:


class MyInterface
{
   virtual int any_object::Method1();
   virtual void any_object::Method2();
}

class Interface1 : MyInterface
{
   int MyClass::Method1()
   {
      printf("%d\n", a);
   }

   void MyClass::Method2()
   {
  
   }
}

class MyClass
{
   int a;
   subclass(MyInterface) interface;
   a = 5;
   interface = class(Interface1);

   void Test()
   {
      interface.Method1(this);
      interface.Method2(this);
   }
}

class MyApp : Application
{
   void Main()
   {
      MyClass object { };
      object.Test();
      getch();
   }
}


This produces two warnings right now which would need to be removed, please don't mind them.

The interesting part is that the data type "subclass(MyInterface)" can act like an object, and allows you to call the methods of that interface (In this example, implemented in Interface1).
However there is no implied "this" pointer (I believe I've only used this so far with the methods with no this pointer (said static in C++), which would be defined as  virtual int ::Method1();)
Using any_object here allows to override the function with the this pointer of our choice, in this case "MyClass".

Although I know the basic workings of interfaces, I haven't had much chance to play with them since I've never programmed in C# or Java myself...
I came up with these particular functionality while implementing the various "drivers" in eC, for example for various platforms, graphics engine etc.
It needs to be polished, and maybe truer interface support should be added to eC. I hope this starts as a discussion point to go forward in deciding how to support the interface paradigm in eC.

Regards,

Jerome

Sam Hu

unread,
Aug 5, 2008, 5:27:14 AM8/5/08
to eC Programming Language
Hi Jerome,

Thanks so much for your quick response,really appreciated!.

Looking forward to your effort to equip eC more and more powerful
while retain the clean and performance of C.

Regards,
Sam
Reply all
Reply to author
Forward
0 new messages