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 726205 - patch: operator overloading for +, -, *, /
patch: operator overloading for +, -, *, /
Status: RESOLVED DUPLICATE of bug 518604
Product: vala
Classification: Core
Component: general
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2014-03-12 22:18 UTC by Richard Wiedenhöft
Modified: 2014-03-13 06:44 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch enabling operator-overloading for +, -, *, / (7.21 KB, patch)
2014-03-12 22:18 UTC, Richard Wiedenhöft
none Details | Review
Testcase (838 bytes, text/x-vala)
2014-03-12 22:19 UTC, Richard Wiedenhöft
  Details

Description Richard Wiedenhöft 2014-03-12 22:18:37 UTC
Created attachment 271660 [details] [review]
Patch enabling operator-overloading for +, -, *, /

Hi,

Attached is a patch and a testcase for an operator-overloading feature i implemented for vala. With this patch you can add attributes like '[Semantics(overloads = "+")]' to a method which enables certain binary operations for instances of the class containing the method.

Using a class like
"""
class Foo {
   [Semantics(overloads="+")]
   public Foo add(Foo foo1) {
      ...
   }
}
"""
a statement like
"var foo3 = foo1 + foo2;"
is equivalent to
"var foo3 = foo1.add(foo2);"

When you are interested in this feature i will implement this for other binary operators too.
Comment 1 Richard Wiedenhöft 2014-03-12 22:19:11 UTC
Created attachment 271661 [details]
Testcase
Comment 2 Richard Wiedenhöft 2014-03-13 06:44:48 UTC

*** This bug has been marked as a duplicate of bug 518604 ***