Re: GInterfaces and API Stability



On Qua, 2007-11-14 at 12:18 +0100, Murray Cumming wrote:
> On Wed, 2007-11-14 at 10:50 +0100, BJörn Lindqvist wrote:
> > On Nov 14, 2007 7:54 AM, Kalle Vahlman <kalle vahlman gmail com> wrote:
> > > Matthias is right IMO, if you need to limit the additions of
> > > GInterface methods for C#, it should be done by the binding. Of
> > > course, if this is a more general problem, *then* it might be
> > > approperiate to refrain from adding interface methods in stable
> > > series. But it doesn't seem to be so.
> > 
> > Lets say GTK+ 2.14 adds the function gtk_ibar_fiddle_foo() to the
> > interface GtkIBar. If I use the GtkIBar interface I except the
> > gtk_ibar_fiddle_foo() method to be there. If a method in another
> > library compiled against GTK+ 2.12 returns a new GtkIBar object then
> > the gtk_ibar_fiddle_foo() method will not be present. The likely
> > result is a segfault in my program when I call gtk_ibar_fiddle_foo().
> 
> I guess that new vfuncs are usually tested for NULL before being called.
> Actually, I'd expect this for all vfuncs. In general, I'd expect the
> interface to adapt to not having its new vfuncs implemented. C can do
> that.

Not all C code does that.  I recall for instance goocanvas, which often
does not check for NULL vfuncs, and so my python programs just segfault
when I forget to implement some method in custom canvas items.

I have to agree that interfaces being frozen would significantly improve
the stability of a platform.  It also would help clarify which APIs are
new to which library version.

And while we're at it, virtual methods (in interface or otherwise)
should _not_ have their return value type changed from void to boolean,
like it happened for some GtkNotebook vmethods between gtk+ 2.10 and
2.12.

> 
> > So yes, adding interface methods is definitely breaks both API and ABI
> > stability.
> >
> > Python bindings doesn't force you to implement all methods an
> > interface specifies so adding interface methods doesn't break the
> > program directly. But you still get a segfault sooner or later when
> > the nonexistent method is called.

So true.

-- 
Gustavo J. A. M. Carneiro
INESC Porto, Telecommunications and Multimedia Unit
"The universe is always one step beyond logic." -- Frank Herbert



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