In this work your doing are there any provisions for determining the current
position in the loop?  i.e. is there anything coming after me?

An example from some code I was just fixing up was taking a list of class
names and combining them into a ;  delimited string (and erroneously
appending a trailing separator), without knowing the current position, or if
something follows you one has to manually keep track of position to
optionally append a ; rather than just call say 'iterator.hasNext()" inside
the loop.

With the syntax below, it would be nice if a new implicit variable was
available which gave up such info, maybe something like:

StringBuilder sb = new StringBuilder();
for each(String className: myListOfClassNames) {
  sb.append(className);
  if (each.hasNext()) sb.append(";");
}

with each being a new implicit variable of some mythical Iteration interface
(this might also provide a getIndex() method to identify which iteration of
the loop were in).

Having access to this information is one of the things I miss with the new
enhanced for loops...

On 10/21/07, Neal Gafter <[EMAIL PROTECTED]> wrote:
>
>
> for each(String element: myList) {
>     if (element.equals ("foo")) break;
> }
>
> for a static method. I'm working separately on a spec/implementation of
> extension methods, which roughly speaking would allow you to use these forms
> interchangeably. In other words, to take advantage of this you wouldn't have
> to make changes to the Collection interface (interface changes break
> backward compatibility in Java).
>


-- 
It`s not the tree that forsakes the flower, but the flower that forsakes the
tree
Someday I`ll learn to love these scars - Bye Bye Beautiful

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "JVM 
Languages" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/jvm-languages?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to