Re: [Vala] Delegation in vala



Кутейников Дмитрий wrote:

A thought on syntax:
*================================*

* class A : Object {
   public void foo() {
       stdout.printf("Object A doing the job.");
     }
 };*

*class B : Object {
*

*   public A a;
   public void foo() {
        a.foo();
     }
 };


Delphi does something like this, and uses the keyword "implements". Delphi also uses Interfaces as the bridge. So Vala would do something like (forgive my syntax errors as I've not got round to doing much Vala recently and have a head full of C# today):

interface IA
{
 public abstract void foo();
}

class A : Object, IA {
  public void foo() {
      stdout.printf("Object A doing the job.");
    }
};


class B : Object, IA {

protected A a implements IA;

};

or maybe:

class B : Object, IA {
 [Implements(IA)] protected A a;

};


**================================*
If there are lots of objects to delegate, there will be LOTS of
unnecessary code with proxy methods.
And when I add/remove method from A, I need to change all B-like
classes manually :(

This is implementing a half house multiple inheritance really, isn't it?

M



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]