Groovy
  1. Groovy
  2. GROOVY-2756

create new user overwritable operator methods for <,==,>,<=,=>,<==>

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: 3.0
    • Component/s: groovy-runtime
    • Labels:
      None

      Description

      as not everything we want to let <,==,>,<=,=>,<==> operate on is a total order, it would be nice to have one of these defined only. Also the current solution with Comparable seems to lead to many problems, because Comparable itself is thought to be used with an exact counter part, but we might want to let it work on other classes as well. for this we should go away from Comparable. I would suggest we write a single method with a bitfield containing flags for <,> and ==. Then the user can throw an exception if a flagged operation is not available, also he can implement only < (100) or > (010) or == (001) or <= (101) or =>(011) or <=> (111). the way to keep backwards compatibility with this would be to add a compareTo method that uses the bits 111.. Well needs more discussion

        Issue Links

          Activity

          Jochen Theodorou made changes -
          Assignee Jochen Theodorou [ blackdrag ]
          Mark Thomas made changes -
          Workflow jira [ 12969782 ] Default workflow, editable Closed status [ 12977528 ]
          Mark Thomas made changes -
          Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
          Mark Thomas made changes -
          Workflow jira [ 12731780 ] Default workflow, editable Closed status [ 12743651 ]
          Mark Thomas made changes -
          Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
          Jochen Theodorou made changes -
          Component/s groovy-runtime [ 16250 ]
          Jochen Theodorou made changes -
          Link This issue is depended upon by GROOVY-2503 [ GROOVY-2503 ]
          Hide
          Jörg Staudemeyer added a comment -

          What ever implementation (one or multiple methods) will be selected, comparison operator methods should be allowed to return arbitrary types, not only boolean (and certainly not only integer) results. Otherwise utilization in DSLs is too much restricted (as is the case with Groovy 1.x).
          See discussions at http://www.nabble.com/Overloading-comparison-operators-td18504388.html and http://www.nabble.com/operator-overloading-td12984525.html.

          Show
          Jörg Staudemeyer added a comment - What ever implementation (one or multiple methods) will be selected, comparison operator methods should be allowed to return arbitrary types, not only boolean (and certainly not only integer) results. Otherwise utilization in DSLs is too much restricted (as is the case with Groovy 1.x). See discussions at http://www.nabble.com/Overloading-comparison-operators-td18504388.html and http://www.nabble.com/operator-overloading-td12984525.html .
          Jochen Theodorou made changes -
          Assignee Jochen Theodorou [ blackdrag ]
          Paul King made changes -
          Link This issue relates to GROOVY-1889 [ GROOVY-1889 ]
          Paul King made changes -
          Link This issue depends upon GROOVY-2576 [ GROOVY-2576 ]
          Paul King made changes -
          Link This issue is related to GROOVY-2576 [ GROOVY-2576 ]
          Paul King made changes -
          Link This issue depends upon GROOVY-2576 [ GROOVY-2576 ]
          Paul King made changes -
          Field Original Value New Value
          Link This issue is related to GROOVY-1765 [ GROOVY-1765 ]
          Jochen Theodorou created issue -

            People

            • Assignee:
              Unassigned
              Reporter:
              Jochen Theodorou
            • Votes:
              2 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:

                Development