After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 741467 - Default constructor for SimpleType structs
Default constructor for SimpleType structs
Status: RESOLVED DUPLICATE of bug 741466
Product: vala
Classification: Core
Component: Structs
0.35.x
Other All
: Normal normal
: 1.0
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2014-12-13 00:06 UTC by pancake
Modified: 2017-03-09 21:23 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description pancake 2014-12-13 00:06:44 UTC
I think that simpletype structs should have a default constructor, which should do nothing, but initialize the local variable with 0s.

```
[SimpleType]
public struct MyTest {
        int foo;
        int bar;
}

public void main() {
        MyTest foo = MyTest ();
}

iface.vala:8.15-8.23: error: `MyTest' does not have a default constructor
```

The way to initialize those structs is the following:

        MyTest foo = {0,0};

This is just a simple struct and this makes no problem, but, if the struct you want to initialize have 80 fields, with some of them of other kinds, you have to specify every single field by hand. Which is tedious and unnecessary because most of the time, structs will be initialized to zero, and then filled some fields progressively.

I think that simpletype structs should have a default constructor.
Comment 1 Luca Bruno 2014-12-13 12:32:38 UTC
See https://bugzilla.gnome.org/show_bug.cgi?id=616600 . Don't remember why I choose that path, but there must be a reason. This issue makes it go backward.
Comment 2 Rico Tzschichholz 2017-03-09 21:23:13 UTC

*** This bug has been marked as a duplicate of bug 741466 ***