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 492483 - generic methods needed
generic methods needed
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Methods
0.3.x
Other All
: High enhancement
: ---
Assigned To: Jürg Billeter
Vala maintainers
Depends on:
Blocks: 471512 531043 540415
 
 
Reported: 2007-11-01 21:20 UTC by xavier.bestel
Modified: 2009-06-03 07:27 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description xavier.bestel 2007-11-01 21:20:58 UTC
Hi,

generic methods would be great to have, i.e. I write a function that operates on List<something> and can apply it to a List<anything>...

Cheers,
        Xav
Comment 1 Jürg Billeter 2007-11-03 20:38:32 UTC
Confirming.
Comment 2 Christian Hergert 2008-06-21 23:23:59 UTC
I'd be very interested in the being able to do the following:

// retrieving gconf value
var x_pos = settings.get<int> ("x_pos");

// some fictitious db api
var title = row.get_column<string> ("title");

// For implementing an api, i wouldn't mind something like the following.
public T get<T> (string param1) {
        var type = typeof (T);

        if (type == typeof (bool))
                return true;
        else if (type == typeof (string))
                return "value";

        return null;
}

// Perhaps that could compile to something like ..
public GValue some_type_get_as (GType type, string param1);
Comment 3 Christian Hergert 2008-06-21 23:26:17 UTC
Rather,

public GValue some_type_get_as (SomeType self, GType type, string param1);
Comment 4 Jürg Billeter 2009-06-03 07:27:12 UTC
commit 37c82ec971b2b200f3d7ca188d1c91d0f34a3f9f
Author: Jürg Billeter <j@bitron.ch>
Date:   Tue Jun 2 17:26:29 2009 +0200

    Add initial support for generic methods
    
    Fixes bug 492483.