[IronPython] Type analysis of expression
Christian Schmidt
christian2.schmidt at gmx.de
Mon Oct 19 21:12:26 CEST 2009
Hi all,
thanks for your discussion.
Actually I'm having an in-memory table of strongly typed columns. The
user can provide per-row (python-)expressions as additional columns. Now
if the user wants his result to be exported to a database (e.g. SQL
Server or Oracle) I need to set a type for each column - also for the
expression columns.
I thought there might be a way to figure out the return type in a
similar way for example Boo (boo.codehaus.org) does at compile time.
When an expression is parsed at runtime, the interpreter also needs to
decide which .NET-functions to call. For strongly typed input these
functions should normally have typed return values... Wouldn't this work
somehow?
If the Boo way is not possible then the only option is evaluating the
expressions for some random rows and coerce to a common type. What would
be the rules? int->float->string is trivial, but what about decimal,
int64, double, ...? I assume python must have implemented these rules
somewhere. How would one have to implement the general function:
Type GetCoercedType(IEnumerable<object> list) { ... }
Thanks,
Christian
More information about the Ironpython-users
mailing list