Search code examples
.netfunctional-programmingexpressionexpression-trees

Expression Trees .net


I would like to get a good grasp on the subject, hence want to ask following questions to the community:

  1. What benefits do expression trees bring to table?
  2. What exactly does this statement mean: "Expression Trees are data compiled as code"?
  3. What common challenges do the Expression Trees and functional programming in the context of .net solve?
  4. What are good online resources to get up the speed on the subj?

Solution

    1. They bring the ability to take your source code and "understand" it at execution time - LINQ providers being the prime target of this

    2. Well, expression trees are often built from source code (e.g. converted lambda expressions) but instead of that source code being compiled into an executable form it's built into a tree which other code can inspect. (More precisely, the compiler takes source code, and emits executable code which in turn builds an expression tree at execution time.)

    3. Expression trees and functional programming seem somewhat orthogonal to me, to be honest. Both often deal with higher order functions, but that's about it.

    4. MSDN perhaps?