This question piggy backs of another question which I raised regarding abusing the IEnumerable interface by modifying an object as you iterate over it.
The general consensus is that no anything that Implements IEnumerable should be idempotent. But .net supports compile time duck typing with the foreach statement. Any object that provides an IEnumerator GetEnumerator() method can be used inside a foreach statement.
So should the GetEnumerator method be idempotent or is it when it implements IEnumerable?
EDIT (Added context)
To put some context round this what I am suggesting is that when iterating over a queue each item is dequeued as it goes. Additionally any new objects pushed onto the queue after the call to GetEnumerator would still be iterated over.
IEnumerable<T> DequeueOnEnumeration()
which can be used likeforeach(T elem in queue.DequeueOnEnumeration())
. That way the semantics are much clearer. – Watkin