GNOME Bugzilla – Bug 597693
Tuple support in Vala
Last modified: 2018-05-22 13:23:50 UTC
We have the comma operator to seperate tuples. We would need support for tuple packing and unpacking, which should work with the = operator. What else would we need?
How to declare methods returning tuples? For tuple variables we could say we require `var`, however, that's not really an option for method return values.
What about public int,string functionReturningATuple(); or public (int,int,int) functionReturniningATuple(); The syntax using brackets would have the advantage that returning a one-tuple would be straightforward. (Just checking: To have an advantage over strings, we talk heterogenous tuples, right?)
An alternative possibility is to use Tuple<int,string>. This would probably reduce syntax complexity and possible ambiguity. (Yes, this is about heterogeneous tuples.)
Yes, that would work as well, although I'd prefer a lowercase T. public tuple<int,string,bool> function( tuple<int,string> inArg )
The Dova branch seems to have preliminary support for that, albeit with a different syntax. Is this still on-topic for the gobject backend?
See also http://tirania.org/blog/archive/2009/Dec-23.html
Yes, it would still be possible to implement this for the GObject backend using the pointer-based generics, i.e., a tuple would just be an array of pointers with a fixed size and type safety.
Pushing this to 2.0, as syntax enhancements are totally out-of-scope for 1.x.
-- 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/48.