ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  Readable Java 1.5
Subject:   I like this
Date:   2003-10-01 07:39:38
From:   anonymous2
Response to: I like this

Using a ':' in the 'foreach' construct seems to me to be in line with the for(;;) syntax, a terse syntax the meaning of which is arguably also not immediately apparent.


Also, the characterisation of 'the java way' as more verbose and clear is fair enough, but this characteristic is quite unevenly applied - cf 'for (;;)'. In particular, there's no real increase in verbosity over C++, when it comes to control flow type of code (that I can think of).


So, there's clearly a precedent for terse initially confusing syntax in Java.
for (T t : coll) is going to be a commonly used construct, so the terseness is ultimately a benefit - I would argue in readability as well as writeability.
Conceptually, it's certainly easier to get one's head around than for(init;test;uh...thingy)


In the end, IMO, your proposals dont really offer anything over and above the 1.5 syntax. But the article was interesting and thought provoking.