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

Functions that return multiple values

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P5 P5
    • None
    • 7
    • specification
    • sparc
    • solaris_10

      A DESCRIPTION OF THE REQUEST :
      I would like to reopen discussion about requests regarding functions that return multiple values . This is in my opinion one of the most missing features in Java language. There were great proposals for syntax and implementation collected in the following feature requests 4639379,
      4034116, 4222792, which this one is duplicate of.

      JUSTIFICATION :
      There was a lots of discussion about potential compatibility issues, etc. a lots of proposals how to get around it. In my opinion this feature is at the same level as auto boxing/unboxing implemented lately years after the original proposal was submitted. Thats why I would like to reopen the discussion about this feature.

      It can be implemented for example similar to auto boxing/unboxing by compiler using anonymous classes or possibly object collections or object arrays (which is what most developers end up doing anyway) without needing to change the format of the byte code.

      The compiler can generate this boiler plate code for the developers and this syntax will greatly simplify coding of many tasks, decreases the amount of boiler plate code that needs to be written, decreases the effort to maintain the boiler-plate code, simplifies the code itself and increases its' readability.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I particularly like the syntax

      public (int, File) getData(int p_stuff){
        return m_anInt, m_aFile;
      }

      ...

      File f; int i;
      (i, f) = getData(2);

            abuckley Alex Buckley
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: