I believe I'm correct is saying that the yield language feature in C# is more accurately described as giving you "Generators" rather than coroutines... with generators being a specific sort of coroutines, but coroutines definitely being more general than them.

Anyway look into lazy lists in F#
[link:research.microsoft.com]
Anything you can do in C# you should easily be able to do in F# using lazy lists.

They are very nice, all the higher order fun as per usual. They are what standard lists are in Haskell.

An aside for an short but interesting read, involving scheme, macros, continuations and coroutines (all fun and games really)
[link:www.ccs.neu.edu]
scroll up to see the context of the discussion.

Another aside... C# implements it's yield statement using a compiler generated state machine for each generator to capture the state and where to resume (makes use of some goto statements ;)) and F# implements lazyness using function closures (and memoizes the result?).

By on 5/29/2006 6:05 PM ()

Thanks for the info. I am still with F# xx.10. where LazyLists

where Streams. I think Streams where a good name for it. But things

change ...

Yours,

Alois Kraus

By on 6/2/2006 4:26 PM ()

I'm interested as to why you prefer the name Stream...

I much prefer LazyList myself... as they are lists and they are lazily evaluated so the name seems much more informative.

By on 6/3/2006 8:18 AM ()

I dod not know LazyList until know. I would not have expected

that it does serve my purpose by simply guessing from its name what it

might be good for. A StreamList would be more expressive for people

which come from a C#/C++ background. From the pure logical point of

view LazyList is fine but it makes it harder for people with another

background to guess what it might do.

Yours,

Alois Kraus

By on 6/4/2006 3:46 AM ()

I am in the process of completing an implementation of coroutines in F#, details are given in a topic in the General Discussions on F# page. These will shortly include C#-style generators as a special case.

By on 9/23/2006 5:13 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper