[Vala] Filling structures



I have already opened a bug few weeks ago..with a patch that works fine,
but I'm still waiting for somebody to review it and commit it.. (jurg? :P)

https://bugzilla.gnome.org/show_bug.cgi?id=618856
https://bugzilla.gnome.org/show_bug.cgi?id=618857
https://bugzilla.gnome.org/show_bug.cgi?id=618933

Today I have falled in a stupid bug caused by me, but vala wasnt warning or so.

The thing is that actually you can assign less fields than the ones existing in
a structure:
----------------------------------------
struct Foo {
    string foo;
    string bar;
    string cow;
}

void main() {
    // should this be allowed??
    Foo foo = { "jej", "jiu" }; //, "jejje" };
}
----------------------------------------

The thing is that by defining such struct in a vapi file and not filling all fields I
fall into a segfault inside Valac.

Should non-all-fields-defined-structure-definitions be allowed by Vala? I think it
can cause of errors and shouldnt be permitted.

Another point is...i dont think will be needed to implement support for named
structure definition like:

  Foo foo = {.foo="jeje", .bar="lala" ..}

Because this kind of constructions are not supported by all C compilers and it can cause errors if you only want to specify a single field. But in this case you
can just do it like:

Foo foo;
foo.foo="lalal";

which is probably cleaner and makes the language more consistent.

What do you think about it? Should I open a bug?

--pancake



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