[IronPython] LINQ from IronPython
Jeff Hardy
jdhardy at gmail.com
Tue Dec 22 22:24:20 CET 2009
On Tue, Dec 22, 2009 at 2:07 PM, Dino Viehland <dinov at microsoft.com> wrote:
> Assuming this is DlrToClrExpressionConverter is converting the expression
> tree and not a call in the produced expression tree the difficulty is
> performing the type inference of the expression tree. In this case
> presumably the conversion to Expression<T> informs us of the type of
> x. From there we could know that it did indeed have Foo and Bar properties
> and those were of some addable type. And so we could probably produce
> a valid expression tree. Not exactly a "simple transformation" but
> we could probably usually pull it off for code like this. I'm not sure
> how predictable it would be when we could or couldn't pull it off though.
I would guess that most of those lambdas are going to be fairly
simple, and hopefully easy to type-infer. For ones that aren't
inferable, the best option would be to give an error.
Given:
id = 1
customers.Where(lambda c: c.Id == id)
Would IronPython be able to know that the type of `id` is `int` at the
appropriate stage of the compiler? Presumably, because it would have
to know the type of `customers` (and thus `c`) to even apply the
extension methods. Would it even have to know the type of `id` to
construct the proper expression tree, given that it knows the type of
`c`?
This rabbit hole goes surprisingly deep! No wonder you haven't tackled it yet.
- Jeff
More information about the Ironpython-users
mailing list