Welcome to Community Server Sign in | Join | Help

Coroutines in Whidbey?


Anders: Language Designing Boy Toy

So what is Scoble censoring here?

Interesting. All the yields at the top lead my guess towards coroutines, but who knows [1]. Hopefully it's something cool that we don't already know about (like generics or partial types, etc.). The very idea that there are undisclosed new features for C# is tres cool.

Anders is coolest thing in the picture anyway, but I'm a card carrying groupie.

[1] This is probably just because I was reading Ajai Shankars .NET Coroutines article in MSDN mag the other night (so now, tristero-like, everywhere I look I see coroutines).

Update: In Scoble's comments, Tim Sneath indicated that what Scoble's obscuring is already announced and EricGu also commented that it's just iterators and some new syntax that he says won't be public until PDC.

I'd read parts of the whitepaperTim Sneath pointed to previously, and frankly it was hard for me to focus after I got all excited about generics and partial types. Going back through it, iterators are discussed, no anchor so I'll recap.

As it turns out, iterators are going to behave like coroutines:

When we implemented the enumerator pattern, we found that we needed to maintain an internal state machine in order to keep track of where we were in the data structure. Iterators have built-in state machines. Using the new yield keyword, we can return values back to the foreach statement that called the iterator. The next time the foreach statement loops and calls the iterator again, the iterator will begin its execution where the previous yield statement left off.
Published Friday, August 15, 2003 8:22 AM by grant

Comments

Friday, August 15, 2003 10:30 AM by grant

# re: Coroutines in Whidbey?

I do believe this is how iterators work in the next version of C#.
Friday, August 15, 2003 6:18 PM by grant

# re: Coroutines in Whidbey?

I'm no expert on Python, but I believe that this type of thing was included in the latest version of Python, 2.3, which came out just a couple of weeks ago.
Friday, August 15, 2003 6:25 PM by grant

# re: Coroutines in Whidbey?

They're part of a number of languages, Python, Ruby, Scheme and probably others. It's a construct that has some solid niche uses which is why I would personally love to see it in C#'s Whidbey incarnation.

EricGu commented on Scoble's post however that what's not showing there is some new iterator syntax (Jesse wins the prize) that won't be public until PDC.

http://www.haloscan.com/comments.php?user=scoble&comment=4247

That doesn't rule out the possibility of iterators working as coroutines, but who knows.

Frankly, generics are going to save so much time/code, I'll be surprised if I notice anything else for a while.
Anonymous comments are disabled