[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-core-libs-dev
Subject:    Some questions on 6312085: The for/in statement should support Iterators/Enumerations
From:       sebastian.sickelmann () gmx ! de (Sebastian Sickelmann)
Date:       2011-08-28 20:25:42
Message-ID: 4E5AA446.6030101 () gmx ! de
[Download RAW message or body]

Hi, i thought about what todo to enable the enhanced-for-loop for 
Iterators and Enumerations.

And it seems to me that the main problem is that the used 
Iterator/Enumeration should not be used in other places( it should be 
"private" for the loop).

As Iterable solves this through creating a new "private" Iterator for 
the Iterable(ex. List/Set/....) it is not geranteed that there are 
concurrent modifications on the Iterable. Typically the iterator solves 
this through checking for concurrent modifications.

If i see it right it should be possible to use every 
Iterator/Enumeration as a source for the enhanced-for-loop which is 
Cloneable too. The main-problem I see is that it is not as easy to pin 
out which Iterator / Enumeration i can put into the for-loop and which i 
cannot. Additionaly i think that would lead into runtime-checks and not 
compiletime-checks which would be really ugly. Let Iterator / 
Enumeration extends Cloneable isn't a good solution because there will 
be some Iterators/Enumerations that are not possible to clone. 
Addtionaly there would be some compatibility issues, ex. let 
Object.clone() do the job will not for every  case) and there maybe more 
compatibiliy issues(binary?) i don't see actually.

As i haven't found any source that brings in the Cloneable 
Iterator/Enumeration solution into account with the enhanced-for-loop it 
maybe a new idea.
Has some a good idea how to get to compiletime-checks with this solution 
and/or how to transparently give the applicationdeveloper the feedback 
he/she needs to intuitional use these?

Thanks for feedback.

-- Sebastian

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic