Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8183548

Comma-expressions shouldn't use any temporary variable

XMLWordPrintable

    • b12

      Comma-expressions shouldn't use any temporary variable. For example, the boxed post-incrementation (this.i++) is actually translated as follows:

      (let /*synthetic*/ final Integer $5222779 = (Integer)this.i in
          (let /*synthetic*/ final Integer $18695331 = this.i = Integer.valueOf((int)(this.i.intValue() + 1)) in
              $5222779));

      Creating a temporary variable $18695331 is useless and should be avoided (it's never used and immediately discarded).

      To achieve this goal, let-expressions have to be refactored to allow more than one statement, probably in the form of block-expressions to give even more freedom.

      Comma-expressions (see Lower.makeComma()) could then be translated naturally without any temporary variable.

            bsrbnd Bernard Blaser
            bsrbnd Bernard Blaser
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: