On Mon, 2010-12-06 at 01:25 +0100, Aleksander Wabik wrote: > As classes not inheriting from Object have different ref and unref > functions (Foo will have foo_ref, and foo_unref, Bar will have bar_ref > and bar_unref), if an object is referenced by the reference of interface > type, there's no possibility to ref and unref this object unless > knowing what ref and unref functions to use! This may be the cause why > creating references of interface type fails, and passing interface type > references to functions do not fail (there's no ref then). > > This is a serious flaw to the object system IMO. It means, that there's > *no way* of having two classes that do not have common ancestor but > implement the same interface. Possible ways to solve this problem:
While I also do not like that aspect of the object system, it's not really something that Vala can change. The object system is defined by GType/GObject, not by Vala. We couldn't use anything like virtual ref/unref functions as we can't expect non-Vala libraries to provide them. My recommendation is to not create too many fundamental classes. By default you should always consider using GObject as base class. If that's not an option for performance or other reasons, create a single fundamental (Mini)Object class in your application or library and use that as base for all other classes and interfaces in the same (part of the) codebase. Jürg _______________________________________________ vala-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/vala-list
