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 597693 - Tuple support in Vala
Tuple support in Vala
Status: RESOLVED OBSOLETE
Product: vala
Classification: Core
Component: Basic Types
unspecified
Other All
: Normal enhancement
: 2.0
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2009-10-07 14:31 UTC by Michael 'Mickey' Lauer
Modified: 2018-05-22 13:23 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Michael 'Mickey' Lauer 2009-10-07 14:31:54 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?
Comment 1 Jürg Billeter 2009-10-07 14:44:54 UTC
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.
Comment 2 Michael 'Mickey' Lauer 2009-10-07 15:16:49 UTC
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?)
Comment 3 Jürg Billeter 2009-10-08 07:19:44 UTC
An alternative possibility is to use Tuple<int,string>. This would probably reduce syntax complexity and possible ambiguity.

(Yes, this is about heterogeneous tuples.)
Comment 4 Michael 'Mickey' Lauer 2009-10-08 11:30:52 UTC
Yes, that would work as well, although I'd prefer a lowercase T.

public tuple<int,string,bool> function( tuple<int,string> inArg )
Comment 5 Michael 'Mickey' Lauer 2009-10-15 23:38:16 UTC
The Dova branch seems to have preliminary support for that, albeit with a different syntax. Is this still on-topic for the gobject backend?
Comment 6 Michael 'Mickey' Lauer 2009-12-24 13:43:09 UTC
See also http://tirania.org/blog/archive/2009/Dec-23.html
Comment 7 Jürg Billeter 2010-03-23 07:18:39 UTC
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.
Comment 8 Michael 'Mickey' Lauer 2018-02-13 08:07:14 UTC
Pushing this to 2.0, as syntax enhancements are totally out-of-scope for 1.x.
Comment 9 GNOME Infrastructure Team 2018-05-22 13:23:50 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/48.