call DYNAMIC function

This forum is meant for questions and discussions about the X# language and tools
Post Reply
User avatar
SHirsch
Posts: 281
Joined: Tue Jan 30, 2018 8:23 am

call DYNAMIC function

Post by SHirsch »

Hi,

I am testing DYNAMIC in connection with IronPython. In C# an IronPython function can be called with the same syntax as methods.

Code: Select all

dynamic f = pyScope.GetVariable(funcName);
returnValue = f();
GetVariable returns in this case type of 'IronPython.Runtime.PythonFunction'.

In X# one has to call:

Code: Select all

LOCAL f := pyScope:GetVariable(funcName) AS DYNAMIC
returnValue := pyEngine:Operations:Invoke(f)
Calling f() throws compiler error 'XS0103: The name 'f' does not exist in current context'.

I am just asking if there is also a simple syntax. If not, it's OK.

Stefan
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

call DYNAMIC function

Post by Chris »

Hi Stefan,

Please try simply "f:Invoke()", does it work? If yes, I will log it for the todo list to also support "f()".

Chris
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
User avatar
SHirsch
Posts: 281
Joined: Tue Jan 30, 2018 8:23 am

call DYNAMIC function

Post by SHirsch »

Hi Chris,

does not work. There is no method Invoke(). Don't care I just thought there is something I missed.
If you and Robert have an empty ToDo list, then maybe ... in year 2038 .... :)

Stefan
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

call DYNAMIC function

Post by Chris »

Hi Stefan,

I think it shouldn't be too difficult to implement it, but we need to know what c# does in this case. From the code, it is not clear what f() really does in c#. If you had this code with strongly typed vars, what would the call to f() translate to? Do you have available documentation for the classes you are using to have a look at?

Chris
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
User avatar
SHirsch
Posts: 281
Joined: Tue Jan 30, 2018 8:23 am

call DYNAMIC function

Post by SHirsch »

Hi Chris,

Thanks for your enthusiasm in this point but I think there are more important things do to than this one.
How about my XIDE wishes? The changed sources I sent you ( call debugger from plug-in and add items to context menus).

Regards,
Stefan
PS: I will prepare a C# and corresponding X# sample when I have more time.
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

call DYNAMIC function

Post by Chris »

Hi Stefan,

Hmm, didn't I already add those a month or two ago? I thought I had informed you about this. Let me check again and will get back to you by PM.

Chris
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
Post Reply