[IronPython] Type analysis of expression
Lepisto, Stephen P
stephen.p.lepisto at intel.com
Mon Oct 19 21:17:31 CEST 2009
Christian,
Would it be possible to leave the columns as text then coerce at the time the data is read from the database? In other words, convert the result of the python expression to a string and store the string in the database. Then, when the result is needed, coerce the string to a more suitable type. In other words, defer when the type needs to be known until the value is used.
-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Christian Schmidt
Sent: Monday, October 19, 2009 12:12 PM
To: Discussion of IronPython
Subject: Re: [IronPython] Type analysis of expression
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
_______________________________________________
Users mailing list
Users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
More information about the Ironpython-users
mailing list