From the documentation, and its name implying, it can be inferred that the value of the CanReduce
property must be set to true for all expressions that can further be decomposed into smaller expressions, and vice-versa.
But upon closer observation, this inference appears not to hold true in all cases. Take the case of LambdaExpression
, which certainly is a composite unit. But the LambdaExpression
class, deriving directly from the Expression
class, does not override the CanReduce
property. The Expression
class defines the CanReduce
property as virtual with an implementation that returns false
, thus implying that a lambda expression is not further reducible, which is not true.
What then is the real meaning of this property?
I think you're reading the documentation wrong. "Reducing" here doesn't mean decomposing into multiple simpler expressions, it means transforming into a single expression that uses more basic operations. For example, consider the following
ListInitExpression
(using C#-like syntax):Calling
CanReduce
on this expression will returntrue
. And callingReduce()
will return:It's not clear to me what should
Reduce()
on aLambdaExpression
return, so it makes sense to me that it's not reducible.