Re: [Vala] Some thoughts about multidimensional arrays



* Jürg Billeter <j bitron ch> [16.09.2009 22:48]:
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

Ok. 
I thought about a runtime library make sense in some cases because vala
produces a lot of redundant code. I had some more festures i want to
have, which require a runtime library, but i can't remember which.

Do you plan to implement some evil hacks to enable reference counting on
none GObject values like strings ...

Regards,
        Frederik
-- 
IRC: playya @ Freenode, Gimpnet
xmpp: playya draugr de

Attachment: signature.asc
Description: Digital signature



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