Allow sealed/final classes
Submitted by Tristan Brindle
Link to original bug (#669541)
Description
Both C# and Java allow the programmer to specify classes which cannot be used as a base class. This allows for some optimisation as the compiler knows how virtual functions will be resolved, and so it can avoid a virtual function call in some cases. C# uses the keyword 'sealed' for this (so I suppose Vala should too), whereas Java uses 'final'.
GObject also has a concept of sealed classes, although not explicitly. If the instance and class structures are defined in the .c file rather than the .h file then it's not possible to inherit from the classes in C. This is the case for GBinding, for example, which cannot be used as a base class (although Vala has no way of representing this).
In the GObject world, using a sealed class like this also has the advantage that private members can be placed in the instance struct rather than in a separate 'priv' struct. This avoids a second pointer dereference when accessing private members, which can be a valuable micro-optimisation in very very tight loops.
Version: 0.41.x