This project is read-only.

Expression parameter

Aug 8, 2013 at 9:39 PM
GetMetaObject(Expression parameter)
What exactly does 'parameter' represent? I know it's a ParameterExpression object, but that is not the whole story I'm looking for. I'm trying to understand what is happening before this method gets called on my object. Is the parameter passed in actually part of a LARGER expression tree?
Aug 9, 2013 at 3:19 PM
If I recall correctly -- and it's been almost four years since I did anything with the DLR -- the expression tree you return can indeed be compiled into a larger expression tree.

Consider a dynamic call site. Through a collaboration between the call site binder and the various implementations of IDynamicMetaObjectProvider, a given set of values ultimately ends up producing a condition (or "restrictions") and an action. The logic at the call site then becomes "if (condition1) { action1(); } else if (condition2) { action2(); } else { DoDynamicBinding(); }". But "action1()" isn't actually a delegate; it's the expression tree returned by the binding process. Furthermore, if none of the conditions were met, then the DoDynamicBinding() process will end up generating a new condition and a new action, and the call site delegate may be rewritten as something like "if (condition1) { action1(); } else if (condition2) { action2(); } else if (condition3) { action3(); } else { DoDynamicBinding(); }

Now if the call site looks something like "foo.Method(bar, baz)", then both the condition and the action have to take into account some information about "foo", "bar" and "baz". The "some information" is represented by the DynamicMetaObject. If foo is something that implements IDMOP, then we might end up invoking BindInvokeMember on foo's meta-object -- and the parameters it gets are meta-objects for "bar" and "baz". BindInvokeMember is able to use the ParameterExpressions for all three values to construct the expression tree being returned or to construct BindingRestrictions which will make up the condition.
Aug 10, 2013 at 1:29 AM
I didn't ask about what I return, I asked about the parameter that is passed in - how is IT created, and is IT part of a larger tree itself.
Aug 12, 2013 at 6:57 PM

I believe the Sympl walkthrough document discusses the parameter argument and why it is there and how to use it.


Aug 12, 2013 at 7:24 PM
Edited Aug 12, 2013 at 7:26 PM
A simplified document that is 80 pages!? LOL. I've seen it already, and there's nothing simple about it for people who are completely new. :)
Aug 12, 2013 at 7:34 PM

I'm not sure why you'd think the document was simplified :-), or simplified from what, but on the up side, you have a good sense of humor :-).



Aug 12, 2013 at 7:50 PM