On 02/18/12 15:10, ant wrote:
On 18 February 2012 21:56, Evan Nemerson<[email protected]> wrote:
public int get_length<T> (T val) {
if ( typeof (T) == typeof (string) ) {
return ((string) val).length;
} else {
GLib.error ("Unable to handle type `%s'", typeof (T).name ());
}
}
Are there any plans to add type bounds to Vala generics?
This would allow something like (e.g., using Java's keyword):
public int get_length<T extends string> (T val) {
return val.length;
}
I.e. the T is qualified to be a subclass of 'string' (not that this is
necessarily possible in Vala), and thus the compiler knows that anything
that can be done to a string can be done to an instance of T.
-m
_______________________________________________
vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list