[Mono-bugs] [Bug 43209][Wis] New - Allow simple return statements inside iterators
bugzilla-daemon@rocky.ximian.com
bugzilla-daemon@rocky.ximian.com
Sat, 17 May 2003 11:35:28 -0400 (EDT)
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by bmaurer@users.sf.net.
http://bugzilla.ximian.com/show_bug.cgi?id=43209
--- shadow/43209 Sat May 17 11:35:28 2003
+++ shadow/43209.tmp.20362 Sat May 17 11:35:28 2003
@@ -0,0 +1,40 @@
+Bug#: 43209
+Product: Mono/MCS
+Version: unspecified
+OS: All
+OS Details:
+Status: NEW
+Resolution:
+Severity: Unknown
+Priority: Wishlist
+Component: Misc
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: bmaurer@users.sf.net
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Allow simple return statements inside iterators
+
+I think we should allow an iterator to return (without an object), to make
+programing simplier. The following code shows an example of a possible use
+of this feature:
+
+ static IEnumerator GetNews (int begin, int size) {
+#if __V2__
+ XPathNavigator nav = new XPathDocument ("myxmlfile").CreateNavigator ();
+ nav.MoveToFirstChild ();
+ XPathNodeIterator itr = nav.SelectChildren (XPathNodeType.Element);
+
+ for (int i = 0; i < begin; i++) {
+ if (!itr.MoveNext ()) return;
+ }
+
+ for (int i = 0; i < size; i++) {
+ yield new NewsStory (itr.Current.Value);
+ if (!itr.MoveNext ()) return;
+ }
+#else
+#error Needs Version 2 features.
+#endif
+ }