D - Java introduces "enhanced for loops"
- Jonathan Andrew (17/17) May 09 2003 Hello,
- C. Sauls (6/6) May 10 2003 I still think we need to settle on a "foreach" syntax and have it
Hello, I saw an article today that I thought might be of interest to you all, describing some of the features present in the upcoming Java release. http://java.sun.com/features/2003/05/bloch_qa.html Of particular interest (or amusement) was their introduction of what they call "enhanced for loops" aka foreach. The syntax they chose is close to some of that proposed in this forum- for(object : collection){ } The reason cited for this syntax as opposed to foreach(object in collection) was to avoid breaking compatibility with existing apps that might use "foreach" and "in" as keywords. Just thought you might like to check it out. OT, but reading this article made me appreciate a lot of the design decisions made in D. Especially the "const" keyword. "public static final double SOMENUM = 1.3333333;; Hmm... just seems a little wordy. =) -Jon
May 09 2003
I still think we need to settle on a "foreach" syntax and have it implemented. Very interesting to see it appear in Java, I'll have to play with that. And I absolutely still say we should have key-value pair looping, a la: for (anarray; key:value) { ... } -- C. Sauls
May 10 2003