Accepted answer

in c# 3, expression trees can represent expressions. hence the name. and they are further restricted to a subset of c# expressions -- no assignment expressions, no expressions involving pointer types, and so on.

in the libraries that will ship with c# 4, we have extended the expression tree library to also support statement trees. however, c# 4 will not automatically translate a statement-lambda into a "statement tree".

that is an obvious and useful feature which we simply did not have time to get to for c# 4. we'll consider it for hypothetical future versions. if you have a really great user scenario for statement trees, i'd love to hear it.

the obvious further extension to all that is declaration trees, which would represent class declarations, struct declarations, and so on. having total homoiconicity between the c# language and the expression tree library would be awesome. it would enable all kinds of interesting metaprogramming scenarios. but that will not happen any time soon, so do not get your hopes up. that's more of a long-term dream of mine which might never happen.

Related Query

More Query from same tag