• Post Reply Bookmark Topic Watch Topic
  • New Topic

How do I do a Java Programming Language feature request?  RSS feed

 
Robert James Liguori
Author
Ranch Hand
Posts: 587
6
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just learned that python allows one to access array elements from the right using negative numbers.  This would be a cool feature for Java.  Anyone know how to do a Java Programming Language feature request?

How do I do a Java Programming Language feature request?
http://robertjliguori.blogspot.com/2017/02/how-do-i-do-java-programming-language.html
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you should start out at http://bugs.java.com/. It contains a section about enhancement suggestions.

I don't think this is going to be possible though, as it would be a breaking change. A lot of code expects -1 to throw an exception, not return the last element. I just wrote a couple of utility methods for that, so instead of writing array[-1] I'd need to call ArrayUtils.get(array, -1).
 
Campbell Ritchie
Marshal
Posts: 56593
172
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The facility to have array indices not starting from 0 was available in Eiffel long before Java® was developed. Since Gosling &c examined several languages including Eiffel before developing Java®, they will have seen that feature. I personally think that starting array indices other than 0/1 is inconsistent with the usual data structure of an array. If they didn't add that feature in 1996, as Rob says, they are not going to add that feature now. Rob has written quite a few utility methods like that (indeed, many people did), and I can try to reconstruct that method.I think that negative indices are inconsistent with the structure of an array, so negative array indices are not necessarily a desirable feature.
 
Campbell Ritchie
Marshal
Posts: 56593
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I merged your stuff with the following thread. I hope that is okay by you.
 
Robert James Liguori
Author
Ranch Hand
Posts: 587
6
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would anyone find syntactical slicing of arrays helpful?



Reference: http://robertjliguori.blogspot.com/2017/02/how-do-i-do-java-programming-language.html

 
Campbell Ritchie
Marshal
Posts: 56593
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not a “beginning” topic. Merging with your other thread.
 
Robert James Liguori
Author
Ranch Hand
Posts: 587
6
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arrays would still start at 0... however, -1 could be -0 if deviated from how Python goes about things.

 
Campbell Ritchie
Marshal
Posts: 56593
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That looks like syntactic sugar for iterating part of an array. Possible, but don't hold your breath.
 
Robert James Liguori
Author
Ranch Hand
Posts: 587
6
Java Netbeans IDE Oracle
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:That looks like syntactic sugar for iterating part of an array. Possible, but don't hold your breath.


 
Robert James Liguori
Author
Ranch Hand
Posts: 587
6
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Robert James Liguori wrote:Would anyone find syntactical slicing of arrays helpful?



Reference: http://robertjliguori.blogspot.com/2017/02/how-do-i-do-java-programming-language.html



should be...

 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Python folks are fond of saying "Python is not Java" so I think a right back atcha would be fair: Java is not Python.

That said, when I first learned Python, I really wished that Java also allowed this kind of code:
 
Campbell Ritchie
Marshal
Posts: 56593
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It should be...to use the proper := operator. I have a language which supports that.
 
Knute Snortum
Sheriff
Posts: 4287
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pascal?
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or Go, at least in some cases.

Regarding array slices, with a few extra methods you can achieve the same. Some even exist in java.util.Arrays.

Sure, it's more verbose, but it's still all possible.
 
Campbell Ritchie
Marshal
Posts: 56593
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute Snortum wrote:Pascal?
No. RuthR
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!