Converting to Ordinary C# 7
In this lesson, we will convert the code from the previous lesson, to ordinary C# 7.
We'll cover the following...
In the previous lesson, we proposed a stripped-down DSL for probabilistic workflows. In this lesson, let’s see how we could “lower” it to ordinary C# 7 code. We will assume that we have all of the types and extension methods that we’ve developed so far.
Naive Approach
The first thing I’m going to do is describe a possible but very problematic way to do it.
We know how C# lowers methods that have yield
return statements: it generates a class that implements IEnumerable
, rewrites the method body as the MoveNext
method of that class, and makes the method return an instance of the class. We could do the same thing here.
Recall that last time we gave three examples, the longest of which was:
probabilistic static
...