Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-3224

Operator overloading. Bind operator to function

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • 1.5.7
    • None
    • syntax
    • None
    • Eclipse 3.4
      Windows XP SP3

    Description

      Currently, groovy maps operators to predefined method names. For example, plus or minus. Those names are the ones in java standard classes such as BigDecimal, but some libraries use different names. Apfloat, for example, uses "add" instead of "plus"

      I'd like to be able to override this behaviour, and define operator in a way similar to c++. That is, leave the current name mapping as default, and allow to override.

      I think, the best option is to use an operator annotation @Operator("+"). This has the advantage that can be used in java classes, and will simply be ignored in pure java projects.

      Attachments

        Issue Links

          Activity

            People

              blackdrag Jochen Theodorou
              rober2d2 Roberto
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: