Hi, Im trying to build a expression evaluator with Linq expressions. Im trying to make It so that all function arguments are lazy evaluated but can't quite get there.
I'm writing in psuedo here but the real thing is linq expressions.
Example expression:
Func1(Func2(10) + 1, Func3(10))
Update
Expression.Call(Func1,
Expression.Add(
Expression.Call(Func2, Expression.Constant(10)),
Expression.Constant(1))
Expression.Call(Func3, Expression.Constant(10))
)
I want the arguments to Func1 to be evaluated at invoke-time that is I want the arguments to be lazy evaluated. It's doable when wrapping the argument expressions inside a lambda expression but if I do that the binary expression Func2(10) + 1 will fail because one can't add a lambda to a constant expression.
The actual function code will look like this:
int Func1(Func<int> arg1, Func<int> arg2)
{
}
arg1 when run will evaluate "Func2(10) + 1"
arg2 when run will evaluate "Func3(10)"
So here I can choose if I want to evalute the argument or not, to get the lazy effect.
Is this possible to accomplish?