Re: [IronPython] calling a named def

2010-11-14 Thread Christian Schmidt
Hi Lee, I've come across the same problem with C++/CLI and System::Func. IIRC the compiler error is a known bug and it will not be fixed - at least for VS 2008. I worked around the missing/buggy System::Func^ by using Delegate^: Delegate^ obj; if (scope-TryGetVariableDelegate^(MyFunc, obj))

Re: [IronPython] Type analysis of expression

2009-10-24 Thread Christian Schmidt
Hi Jeff, I know that the return type of a dynamic expression cannot be determined in general. But what would be a pragmatic way to guess the return type of an expression? Can you give some examples of expressions you need to infer? arithmetic operations: a + b / c functions: sqrt(a) logical

Re: [IronPython] Type analysis of expression

2009-10-20 Thread Christian Schmidt
Hi Vernon, Maybe I'm missing the point -- are you trying to load data into an existing data table, or to DEFINE a new data table? Sorry for not clarifying this. I'm able to export to _new_ tables, which will be created at runtime. For existing tables we could easily work out with the

[IronPython] Type analysis of expression

2009-10-19 Thread Christian Schmidt
Hello, we are using IronPython embedded into our application to evaluate user defined expression. The variables used in the expressions are strongly typed and the results need to be written back into a database. I know that the return type of a dynamic expression cannot be determined in

Re: [IronPython] Type analysis of expression

2009-10-19 Thread Christian Schmidt
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

[IronPython] Documentation/Example for Python expressions

2009-08-26 Thread Christian Schmidt
Hi, we're using IronPython 2.6 within our C#-application to evaluate user defined expressions. Where can I find end user examples and documentation I can link to for python expressions? I looked at http://docs.python.org/reference/expressions.html but this is too programmer oriented.

Re: [IronPython] Documentation/Example for Python expressions

2009-08-26 Thread Christian Schmidt
Hi Bruce, thanks for your answer. How much python will you let your users execute? Potentially everything that can be put into ScriptEngine.CreateScriptSourceFromString( Expression, _SourceCodeKind.Expression_).Execute(ScriptScope) Are they just typing in formulas or are they

[IronPython] Memory Leak in CreateScriptSource?

2008-12-25 Thread Christian Schmidt
Hi, the following code snippet allocates constantly more and more memory. Moving .Compile() outside the loop works as expected. private static void LeakTest() { var runtime = Python.CreateRuntime(); var engine = runtime.GetEngine(py); var sum = 0.0; while (true) { var code =

[IronPython] Usage of IronPython 2 Parser

2008-09-10 Thread Christian Schmidt
Dear community, please could anyone provide an example of how to create a parser in IronPython 2.0 Beta 4. The examples I found are outdated (based on IP 2.0a3) and my own try ended in NullReferenceException (see my post on 2008-09-08). Thanks Christian

Re: [IronPython] Determine used SymbolIds in an expression

2008-09-08 Thread Christian Schmidt
Hi, I found some answers to my own questions. But I'm stuck again... how can I determine the Symbols or SymbolIds that are used in an (IP2-)expression? Obviously I need to parse the expression. Where can I find a small sample or tutorial on parsing in IP2?

Re: [IronPython] CustomSymbolDictionary and conversions

2008-08-25 Thread Christian Schmidt
Hi sesh, thanks for your answer. What would be the approach to extend a ScriptScope by the properties of an object? Or in other words: How can I evaluate an expression in an object's scope? Any valid IronPython script snippet can be executed in the context of a scope. Since an expression is

Re: [IronPython] How to call a function passing parameters

2008-08-22 Thread Christian Schmidt
@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com -- -- Dr. Christian Schmidt ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

[IronPython] CustomSymbolDictionary and conversions

2008-08-21 Thread Christian Schmidt
Hi, I've derived from CustomSymbolDictionary to add specific variables to a scope (see seshadripv's blog). What I would expect from a method called TryGetExtraValue is that only if the scope (where the IAttributesCollection was added in the constructor) cannot find the SymbolId, the

[IronPython] Determine used SymbolIds in an expression

2008-08-21 Thread Christian Schmidt
Hi, how can I determine the Symbols or SymbolIds that are used in an (IP2-)expression? Obviously I need to parse the expression. Where can I find a small sample or tutorial on parsing in IP2? Thanks, Christian ___ Users mailing list

Re: [IronPython] CustomSymbolDictionary and conversions

2008-08-21 Thread Christian Schmidt
Hi Seshadri, thanks for your answer. The TryGetExtraValue and TrySetExtraValue methods can return a false for SymbolIDs that they don't maintain. Those values will be looked up in the actual scope. I see, makes sense. When accessing the baseScope from your example, isn't

Re: [IronPython] IP 2: Execute multiple expression in different scopes

2008-08-19 Thread Christian Schmidt
Hi Curt, thanks for your answer. It's an interesting idea, to hand over the items as function arguments. I was trying to add them to the ScriptScope. But I'm still stuck with calling the function: ScriptScope scope = ScriptRuntime.Create().GetEngine(py).CreateScope(); scope.Execute(from

Re: [IronPython] IP 2: Execute multiple expression in different scopes

2008-08-19 Thread Christian Schmidt
brought up by Fernando Correia - Func IIRC is only defined in .net 3.5, right? Thanks, Christian On Tue, Aug 19, 2008 at 12:09 PM, Christian Schmidt [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Hi Curt, thanks for your answer. It's an interesting idea, to hand over the items

Re: [IronPython] IP 2: Execute multiple expression in different scopes

2008-08-19 Thread Christian Schmidt
Hi Dody, If you are not using this in a .Net 3.5 website project, you can use alias to deal with this Beta 4 issue. I'm not using IP2 in a website project, but would like to use it in a 3.5 project. How do I have to set this alias? Thanks, Christian

Re: [IronPython] IP 2: Execute multiple expression in different scopes

2008-08-19 Thread Christian Schmidt
Hi Dody, thanks for your help. delegate object FunctionProcess(object[] params); I've already tried this one and also delegate object FunctionProcess(params object[] p); scope.GetVariableFunctionProcess (Process) But get an ArgumentException (Invalid type of return expression value at

Re: [IronPython] IP 2: Execute multiple expression in different scopes

2008-08-19 Thread Christian Schmidt
Hi Dody, thanks for your patience. delegate System.Int32 FunctionProcess(System.Int32[] parameters) This assumes that your Python implement will only do integer operation. If you are going to use the delegate for generic holder of arguments, don't forget to cast for example: delegate

Re: [IronPython] IP 2: Execute multiple expression in different scopes

2008-08-19 Thread Christian Schmidt
Hi Dino, Is there a reason ObjectOperations.Call(scope.GetVariable(Process), args) doesn't work? It seems that ObjectOperations does not have a static method Call. Where do I get an ObjectOperations instance from? I found another solution: Delegate process =

[IronPython] IP 2: Execute multiple expression in different scopes

2008-08-11 Thread Christian Schmidt
Hi, I'm trying to figure out the best way to embed IP 2 expressions into C# to implement the following: I have given a scope that consists of an IListobject and a mapping of the list's indices to a name. Now I want to evaluate several expressions within this scope. After this, the scope

[IronPython] replacing engine.evaluate by CreateLambda

2007-09-24 Thread Christian Schmidt
Hello community, How can I replace the 3 parameter Evaluate-function from PythonEngine engine.Evaluate(expression, module, locals) where expression is a string, module is a EngineModule and locals is a IDictionarystring, object by something like delegate object

[IronPython] Python as embedded expression evaluator

2007-09-18 Thread Christian Schmidt
Hi all, I'm using IronPython 1.1 as an expression evaluator in an C# application. These expressions are evaluated repeatedly with different variables. Therefore I should use CreateLambda instead of Evaluate. I have the variables in an IDictionarystring, object. But I don't know what the

[IronPython] Usage of Parser.FromString

2006-08-14 Thread Christian Schmidt
Hi, I'm trying to fill a treeview with the statements found in a embedded python script. How do I traverse through the tree of parsed statements? using IronPython; using IronPython.Compiler; using IronPython.Compiler.Ast; void doparse(string txt) { SystemState ss = new

[IronPython] special method equivalents in C#

2006-08-13 Thread Christian Schmidt
Hi, I want to implement special methods of classes in C# that I use from ironpython. For example C#'s equivalent of Python's __iter__ is to derive from IEnumerable, __getitem__ corresponds to this[object], __init__ and __del__ to constructor and destructor, __str__ to toString(), __hash__ to