4 ms·
Trying to wrap my head around this...as someone coming from .NET land, maybe someone can explain it in terms I understand? In F#, the default method of asynchr
by Nelkins 9y ago
Trying to wrap my head around this...as someone coming from .NET land, maybe someone can explain it in terms I understand? In F#, the default method of asynchronous programming is the async computation expression. That is, there is a type Async<'T> which represents a computation that can be executed to return a result of type 'T. The computation itself is "lazy" in the sense that it isn't hot at the time of creation, and can be executed multiple times to produce a result. This is in contrast to the C# way of doing things, in which a function has a return type of Task<'T> which is (under normal circumstances) kicked off at time of creation and can only be run a single time. Is this proposal advocating for the more F#-y way of doing things, or the more C#-y way of doing things?
- kllrnohj 9y agoC# has what you've described as well in the form of yield return. It's largely the same thing to the compiler in that it needs to transform a method into a stack-less state machine. Whether or not the state machine is evaluated lazily on demand or concurrently is mostly irrelevant and just depends on the specific problem in question.