-
Enhancement
-
Resolution: Duplicate
-
P5
-
None
-
7
-
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);
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);
- duplicates
-
JDK-8061407 Multiple return values from a method
-
- Closed
-
- relates to
-
JDK-4034116 Functions that return multiple values
-
- Closed
-
-
JDK-4639379 support multiple return types in the Java language
-
- Closed
-
-
JDK-4222792 Please allow Multiple Return Values
-
- Closed
-