[Vala] derived structs



The fact that vala does not (yet) have a final specification gives great opportunities to very useful extensions. The use of member functions related to structs is one feature in the current implementation, that I found particularly usefull. It appears that the parser will parse structs just like classes. This is useful, since one can derive one struct from another one as well. One can obviously not use vitual functions for derived classes since there is no vtable to dispatch them. It is however usefull to allow at least one derived struct for any given application. This makes it possible to allocate huge amounts of data in an array without any overhead. It is then usefull to save the base of such a struct to disk when needed, and to use the derived part of the struct to store state relevant to the struct in the context of the application. This use case is especially practical in cases where millions of small structs are to be processed while avoiding the overhead of reference counting and detailed memory allocation etc. This is relevant for applications that treat the datacollection as one integral unit that is to be kept as such as one unit in memory as well.

The implied question related to the use case described, concerns:

1. An estimate of the ease to implement derived structs in the current, quite modular, vala architecture.
2. Any plans to implement such a feature in vala in the (long) future.

J. Smit




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