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 638199 - Support 'unowned var' (unowned compiler-typed variables)
Support 'unowned var' (unowned compiler-typed variables)
Status: RESOLVED OBSOLETE
Product: vala
Classification: Core
Component: general
0.18.x
Other Linux
: Normal enhancement
: 2.0
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2010-12-28 17:24 UTC by Travis Reitter
Modified: 2018-05-22 13:50 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
allow unowned and const modifiers to var declarations (6.17 KB, patch)
2011-12-19 05:34 UTC, Aaron Andersen
none Details | Review

Description Travis Reitter 2010-12-28 17:24:06 UTC
valac currently doesn't support unowned auto-typed variables.

This leads to odd development patterns -- the 'preamble' for a variable can flip more than a single keyword at a time when optimizing types (whether for readability, fewest copies, etc.). Eg,

        var     bar = func_that_allocates_result ();
->
unowned FooType bar = func_that_does_not_allocate_result ();

Whereas if we supported unowned var, a return type change on the right side would look like:

        var bar = func_that_allocates_result ();
->
unowned var bar = func_that_does_not_allocate_result ();


Ideally, we would use 'var' type for all variables that are declared and assigned to in the same line (whether or not they're unowned).
Comment 1 Travis Reitter 2010-12-28 17:33:26 UTC
Just to clarify the examples above:

Current situation:

        var     bar = func_with_owned_result ();
->
unowned FooType bar = func_with_unowned_result ();

Whereas if we supported unowned var, a return type change on the right side
would look like:

        var bar = func_with_owned_result ();
->
unowned var bar = func_with_unowned_result ();
Comment 2 Alexander Larsson 2011-08-17 08:14:23 UTC
Yeah, i'd like that too.

Also, it could possibly support other modifiers too, like const.
Comment 3 Aaron Andersen 2011-12-19 05:34:36 UTC
Created attachment 203838 [details] [review]
allow unowned and const modifiers to var declarations
Comment 4 GNOME Infrastructure Team 2018-05-22 13:50:05 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/vala/issues/152.