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

Change precedence priority of ** compared to pre/post inc/dec and unary plus/minus

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • None
    • None
    • None
    • None

    Description

      Currently the precedence order is:

      level 1: post inc/dec
      level 2: power
      level 3: pre inc/dec
      

      The original intention, I believe, was always:

      level 1: post inc/dec
      level 2: pre inc/dec
      level 3: power
      

      This leads to some unintuitive behavior:
      while these are the same:

      println (-9 + 2)  //  -7
      println ((-9) + 2)  //  -7
      

      these are different:

      println (-9 ** 2)  //  -81  actually: println (-(9 ** 2))
      println ((-9) ** 2)  //  81
      

      Similar anomalies occur between ** and ++/--

      Attachments

        Activity

          People

            paulk Paul King
            paulk Paul King
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: