GNOME Bugzilla – Bug 638199
Support 'unowned var' (unowned compiler-typed variables)
Last modified: 2018-05-22 13:50:05 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).
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 ();
Yeah, i'd like that too. Also, it could possibly support other modifiers too, like const.
Created attachment 203838 [details] [review] allow unowned and const modifiers to var declarations
-- 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.