Languages such as Simula 67 contain a general concept of coroutines that
allow the execution of a method to be suspended without rolling back the
stack and then later resumed at the same place as it has been suspended.
The C# iterators seem to be a special case of this general suspend/resume
concept. The "yield" statement suspends the execution of the current method
and calling MoveNext() resumes it.
I think it would be cleaner to introduce the general suspend/resume concept
to C# and then implement C# iterators on top of this general foundation. The
way C# iterators have been added to C# seems to be somewhat ad hoc; it is a
very specific and distinct functionality that does not naturally blend with
the rest of the language.
Jiri
allow the execution of a method to be suspended without rolling back the
stack and then later resumed at the same place as it has been suspended.
The C# iterators seem to be a special case of this general suspend/resume
concept. The "yield" statement suspends the execution of the current method
and calling MoveNext() resumes it.
I think it would be cleaner to introduce the general suspend/resume concept
to C# and then implement C# iterators on top of this general foundation. The
way C# iterators have been added to C# seems to be somewhat ad hoc; it is a
very specific and distinct functionality that does not naturally blend with
the rest of the language.
Jiri
Comment