|
|
|
As in this pseudo-IL?
if <iterator> == null goto or <enumerator> = <iterator>.GetEnumerator() flag = false goto cond :body flag = true <loop_block> :cond if <enumerator>.MoveNext() goto body if flag goto end :or <or_block> :then <then_block> :end If that's the case, I think it's a separate ticket. The real question is whether we should behave this way on null values. It wouldn't affect while, only the way in which for interprets a null iterator. Yes as in this pseudo-IL.
Imho this adds more value and potential usages to the 'or' construct while being consistent ('or' is executed when you do not enter the loop). What do you think? Rodrigo? Avish? Also I guess this doesn't deserve a separate ticket for itself, in some way it is still about the addition of the 'or' keyword which haven't been in a release yet, but do as you prefer of course. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This code 'obviously' results in a NullReferenceException.
However I think the 'or' construct should handle this nicely, as this match the semantic (loop is not entered) and would allow shrinking the common scenario below :
Thoughts?