Re: [Vala] Some thoughts about multidimensional arrays



Hi,

On Wed, 2009-09-16 at 20:03 +0200, Frederik Sdun wrote:
I wrote some code using multidimensional arrays yesterday and realized
it is not .... perfect, especially if you use strings.

Every array uses an additional _length and and _size gint. size is the
allocated size, length the actual use fields. Because every array uses
such data, why not pack them into a struct? Let's call it
ArrayDim[ension]:

While I agree that it intuitively makes a lot more sense to store the
length/size in a struct, it's, unfortunately, not realizable. The main
reason is that it would be incompatible to everything else out there.
This means that Vala applications coult not access/pass arrays from/to C
libraries unless you support two array types, one that is compatible and
one that uses these structs.

An other issue is that there is no good place to define these structs as
there is no Vala-specific runtime library. This could probably be worked
around but the main issue is compatibility as mentioned above.

BTW: I am experimenting with a new runtime library that could be used
for Vala applications as an alternative to GLib, and there I sacrifice
compatibility for features and sane definitions, this includes moving
everything that belongs to the array into a single struct.

Jürg




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