The problem you brought up is the one area of interfaces that I didn't investigate more thoroughly when I was writing that blog post. I always wanted to go back and figure out what was going on, but never did.
Vala probably could automate some of this, but I'm not sure. If you think about it, that's a big reason for Vala's existence: to automate generating GObject code. Perhaps Jürg or Luca could chime in and discuss the issue. -- Jim On Mon, Aug 27, 2012 at 12:13 AM, Thomas Jollans <[email protected]> wrote: Hi Jim, First of all, that looks like a good blog post. I'll have to take the time to actually read it later today. Giving this some further thought - (judging from Vala-generated C code) GObject interfaces are basically just jump tables that are populated in interface initialization functions, named [class]_[interface]_interface_init() by Valac. There is no built-in automatism, at least none that's used by Valac, so it seams to me that Valac *could* look for missing methods in other interfaces and automatically generate wrapper functions (or simply set the function pointers accordingly, assuming the types are right? I'm not sure about this) It looks like GObject in principle supports the rather ugly case of a class implementing two interfaces with methods of the same name but with differing signatures. Vala doesn't handle this case very well as far as I can see; it certainly doesn't throw an error or print a warning in the face of such ambiguity - there's no way to specify which method is supposed to be implemented if it's not obvious, is there? There may be a need for some more checks in the compiler, and maybe some additional annotations. Cheers Thomas On 27/08/12 04:18, Jim Nelson wrote: > Your problem lies here: > >> interface IBar : IFoo >> { >> public virtual void bar () >> { >> } >> } > > Because IBar is an interface, it doesn't inherit from IFoo. Rather, in > Vala that syntax means whatever class implements IBar's interface must > also implement IFoo (or, IFoo is a prerequisite interface for IBar). > For whatever reason, although interfaces may implement code, in Vala an > interface cannot implement a prerequisite's methods. > > I don't know the exact reason why. I suspect it's a limitation of > GObject and not Vala. > > I discuss interfaces on the Yorba blog: > http://blog.yorba.org/jim/2011/11/a-few-of-my-favorite-vala-things-interface.html > > > -- Jim
_______________________________________________ vala-list mailing list [email protected] https://mail.gnome.org/mailman/listinfo/vala-list
