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 668474 - Support generic type constraints
Support generic type constraints
Status: RESOLVED OBSOLETE
Product: vala
Classification: Core
Component: Generics
unspecified
Other All
: Normal enhancement
: ---
Assigned To: Vala maintainers
Vala maintainers
: 694895 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2012-01-23 08:46 UTC by Evan Nemerson
Modified: 2018-05-22 14:19 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
point class (385 bytes, text/plain)
2017-02-06 13:46 UTC, Muhannad ALrusayni
Details

Description Evan Nemerson 2012-01-23 08:46:16 UTC
It would be nice if Vala supported constraints on generic types.

I'm not exactly in love with the syntax C# uses, but they do it like this: http://msdn.microsoft.com/en-us/library/d5x73970(v=vs.80).aspx
Comment 1 Felipe Lavratti 2016-11-28 18:12:31 UTC
Someone asked for the same feature in Stack Overflow: http://stackoverflow.com/questions/40692468/bounded-type-parameters-in-vala
Comment 2 Al Thomas 2016-11-30 15:31:06 UTC
*** Bug 694895 has been marked as a duplicate of this bug. ***
Comment 3 Muhannad ALrusayni 2017-02-06 13:46:05 UTC
Created attachment 345031 [details]
point class

Hi, I was trying to write Generic Point<T> class , but I wasn't able to do some arithmetic operation and when I try to do so, I got error message says : 
error: Arithmetic operation not supported for types `T' and `T'

That does make sence to me, since T is not knowen type and it could 'value-type' or 'reference-type' or anyother type, and as this bug says "constraints on generic types" would slove this issue, for example if I mark T to be value-type in my Point<T> class then I will be able to do arithmetic operation in Point<T> and that would be great.

I have attached a testcase that (simplefide Point<T> class), you can see if needed.
Comment 4 GNOME Infrastructure Team 2018-05-22 14:19:00 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/271.