Hi Matt, On Fri, 2007-12-07 at 09:20 -0500, Matt Brown wrote: > I wanted to tell how awesome this project is (as if you didn't know). > It is one of those ideas > that is so elegant it makes me a little jealous. It's always annoyed me > that separate, distinct concepts > like clean OO syntax and runtime engines are usually welded together as > if they required one another. > Thanks for Vala, I really hope the project grows to realize it's > incredible potential.
Thanks! > Why can't class inheritance from Glib.Object be implicit instead of > explicit? > > So Vala uses GObject to implement classes. Why does a programmer need > to know that > internal implementation detail? > > Is there a strong need for classes that do not inherit from GObject? > these are just mapped to structs, and structs are already available in > the language, right? While most classes (should) derive from GObject, it's not always the case. For one there are many libraries that don't use GObject at all or don't use GObject for all class types and we want to be able to use such libraries from Vala. Examples include GLib itself, cairo, libxml2, and many more. There are also some rare cases where you want to define non-GObject in Vala, either for performance reasons (when you need to create hundred thousands of instances in short time) or if you need more control about the field layout. You can also define new foundation types in Vala by deriving from GLib.TypeInstance, such types can be used as lightweight objects, that's what GStreamer does with GstMiniObject. The difference between structs and classes in Vala is that structs are value-types and classes are reference-types, as documented in the reference manual[1]. That's the same as in C#. In previous versions of Vala all classes derived from GObject; there was an attribute to mark a struct as a (non-GObject) reference type. However it was very confusing that some structs were value-types and other structs were reference-types. While the current solution requires you to type an extra ": Object" from time to time (compare that to the C boilerplate), the approach makes a lot more sense, in my opinion. Jürg [1] http://www.vala-project.org/doc/vala/types.html _______________________________________________ Vala-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/vala-list
