3 ms·
Why not just write it in C#.
by dinkumthinkum 16y ago
Why not just write it in C#.
- fleitz 16y agoBecause in F# you can write that code today rather than in a year or two when C# 5.0 is released. Also, the pattern used by F# to do this sort of thing is exposed to the user so you can create any kind of monad instead of just one for async. In F# this behavior is integral to the language and not just syntactic sugar for a couple 'special' cases. So instead of learning one syntax for continuations and another for async, sql, etc, etc. You just have one system to learn that can be applied to many different problems, and you don't have to wait for Anders to bless your problem as important enough to have syntactic sugar added. The other thing to note is that there will be many 'special cases' about using this code that don't work with typical C# code because of its mutability. It's similar to all the weirdness around using the yield statement. Like how you can't have an out parameter on a method that uses a yield statement and some weirdness around exceptions.
- kevingadd 16y agoSo far it seems like they're doing a good job of reducing the special cases when it comes to this feature. It handles exceptions correctly, and you can 'await' any object that implements a trivial interface, so it's not just limited to the APIs they've decided to bless.