Re: [Vala] Interfaces and Mixins

2010-06-19 Thread Jan Hudec
On Tue, Jun 15, 2010 at 16:09:06 -0700, Robert Powell wrote:
 On Tue, Jun 15, 2010 at 4:00 PM, tecywiz121 tecywiz...@hotmail.com wrote:
  Actually in my other interfaces, it works fine.  I'm just not sure if
  I'm allowed to override a method declared in Flushable in Entity.
 Do your other interfaces derive from another interface?  I think that is
 where trouble lies, or used to lie.

Well, the problem is that interfaces don't derive from each other, they
*depend* on each other. They therefore can't override each other's method --
they can only call them.

I think the best you can do is to have a helper method in the Entity
interface and use it to implement Flushable in the concrete class.

-- 
 Jan 'Bulb' Hudec b...@ucw.cz
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Interfaces and Mixins

2010-06-15 Thread Robert Powell
On Sat, Jun 12, 2010 at 7:03 AM, tecywiz121 tecywiz...@hotmail.com wrote:

 Hey,


Hey!



 The following code won't compile unless I create a flush() in Concrete,
 but I can't seem to access Entity.flush() at all, any way around this
 that doesn't involve making Entity a class?
 public interface Flushable : Object

{
public abstract void flush();
 }

 public interface Entity : Object, Flushable
 {
public virtual void flush()
{
// Do Something
}
 }



What are you trying to accomplish by having both Flushable and Entity?  I
think you are trying to create different mixin implementations of Flushable,
which seems like a perfectly reasonable thing to do.

You can access Entity.flush by casting this to an Entity.  I think you'll
find that when you refer to the object you will receive GObject warnings
about cannot add interface type 'Entity'.  Even without the name collision
of flush, this GObject warning will still occur.

Deriving interfaces from interfaces is definitely broken.  You might want to
submit a bug.

Hope that helps,

Rob
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Interfaces and Mixins

2010-06-15 Thread tecywiz121
On Tue, 2010-06-15 at 14:50 -0700, Robert Powell wrote:
 On Sat, Jun 12, 2010 at 7:03 AM, tecywiz121 tecywiz...@hotmail.com
 wrote:
 Hey,
 
 Hey!
  
 
 
 The following code won't compile unless I create a flush() in
 Concrete,
 but I can't seem to access Entity.flush() at all, any way
 around this
 that doesn't involve making Entity a class?
 public interface Flushable : Object
 {
public abstract void flush();
 }
 
 public interface Entity : Object, Flushable
 {
public virtual void flush()
{
// Do Something
}
 }
 
 
 
 What are you trying to accomplish by having both Flushable and Entity?
 I think you are trying to create different mixin implementations of
 Flushable, which seems like a perfectly reasonable thing to do.

I am trying to have a type hierarchy like so

Flushable
| \
|  \
 Entity \
|\
| FlushableNonEntity
 SomeObj

Where SomeObj's implementation of Flush comes from entity, but
FlushableNonEntity's does not.

 You can access Entity.flush by casting this to an Entity.  I think
 you'll find that when you refer to the object you will receive GObject
 warnings about cannot add interface type 'Entity'.  Even without the
 name collision of flush, this GObject warning will still occur.

Wouldn't the following code (not sure, haven't tried) just recurse
infinitely?

public object Bob : Object, Flushable, Entity
{
public void flush()
{
((Entity)this).flush();
}
}

 Deriving interfaces from interfaces is definitely broken.  You might
 want to submit a bug.

Actually in my other interfaces, it works fine.  I'm just not sure if
I'm allowed to override a method declared in Flushable in Entity.

 Hope that helps,
 
 Rob

It kinda does, thanks

Sam


___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Interfaces and Mixins

2010-06-15 Thread Robert Powell
On Tue, Jun 15, 2010 at 4:00 PM, tecywiz121 tecywiz...@hotmail.com wrote:

 On Tue, 2010-06-15 at 14:50 -0700, Robert Powell wrote:
  On Sat, Jun 12, 2010 at 7:03 AM, tecywiz121 tecywiz...@hotmail.com

 You can access Entity.flush by casting this to an Entity.  I think
  you'll find that when you refer to the object you will receive GObject
  warnings about cannot add interface type 'Entity'.  Even without the
  name collision of flush, this GObject warning will still occur.

 Wouldn't the following code (not sure, haven't tried) just recurse
 infinitely?

 public object Bob : Object, Flushable, Entity
 {
public void flush()
{
((Entity)this).flush();
 }
 }


As long as Entity's implementation of flush doesn't call Bob's
implementation of flush, I don't see why it would recurse.


  Deriving interfaces from interfaces is definitely broken.  You might
  want to submit a bug.

 Actually in my other interfaces, it works fine.  I'm just not sure if
 I'm allowed to override a method declared in Flushable in Entity.


Do your other interfaces derive from another interface?  I think that is
where trouble lies, or used to lie.

Rob
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list