Feedback with 5 minutes Experience of C# Script Engine

General discussions related to using the C# Script Engine in APL+Win.

Moderators: Tech Support, phpbb_admin

Feedback with 5 minutes Experience of C# Script Engine

Postby Ajay Askoolum » May 9th, 2013, 4:26 pm

Congratulations on implementing []cse as a means of accessing C# directly.

However:

- Getting []cse is NOT intuitive. I had downloaded this as soon as it appeared. At that time, it prompted me for a password (which was not supplied). I downloaded it again today & installed it by trial and error. Hence my comment: 'NOT' intuitive.
- I am informed that I have 23 days to complete the evaluation. I think this time span is just too short to put []cse through its paces.
- I think []cse implements a COM Object. I like COM but in the context of C# scripting, I think it introduces undesirable features: see below.

Example 1: COM Coercion - in C#, dt is an object but []cse returns a scalar value (n time units from a reference point, I believe)

c ⎕cse 'Exec' 'System.DateTime dt= System.DateTime.Now;'
c ⎕cse 'GetValue' 'dt'
41403.87607

Example 2: COM Transposition - in C# array is of shape 2 3 but []cse turns it into an array of shape 3 2

c ⎕cse 'Exec' 'int[,] mystr=new int[,]{{1,2,3},{4,5,6}};'
c ⎕cse 'GetValue' 'mystr'
1 4
2 5
3 6

Any comments?
Ajay Askoolum
 
Posts: 650
Joined: February 22nd, 2007, 2:16 am
Location: United Kingdom

Re: Feedback with 5 minutes Experience of C# Script Engine

Postby joe_blaze » May 14th, 2013, 9:46 pm

Hi Ajay,

We appreciate your comments, so please keep them coming.

The issue with an interface between C# and APL+Win is that APL+Win only has Int32, double, and string data types, whereas C# has many more data types, including custom types which can be programmer created. There is no intention with the availability of the CSE to add all these C# data types to APL+Win. If one needs that there is VisualAPL.

In APL+Win the CSE 'GetValue' method will return a value when querying the value of a C# DateTime variable because the Microsoft Com interface makes that translation, but it is not what I would suggest doing. Instead if via the CSE 'Exec' method one defines 'DateTime dt = DateTime.Now;' for example, then use []CSE 'GetValue' 'dt.Year' or []cse 'GetVaue' 'dt.millisecond' for example. The programmer using the CSE needs to be aware of the limitations of APL+Win and understand the underlying object model of 'complex' C# data types which in the end reduce to the C# value types, some of which have analogous APL+Win data types.

Joe
joe_blaze
 
Posts: 383
Joined: February 11th, 2007, 3:09 am
Location: Box 361 Brielle, NJ 08730-0361

Re: Feedback with 5 minutes Experience of C# Script Engine

Postby joe_blaze » September 13th, 2013, 2:06 am

Hi Ajay,

I didn't comment on your 2nd example until now:

Ajay noted: COM Transposition - in C# array is of shape 2 3 but []cse turns it into an array of shape 3 2

This transposition is the result of differences in the row and column orientation between APL+Win and most other programming languages. Basically APL+Win is not going to change C# and C# is not going to change APL+Win, so the programmer venturing into both spheres of influence has to be aware of these differences. In a recent version of APL+Win the 'deep transpose' system function (⎕dtr) was implemented to help with this particular difference. See the attached pdf-format document for an example.

Joe
Attachments
APL+Win Deep Transpose System Function.pdf
(12.72 KiB) Downloaded 153 times
joe_blaze
 
Posts: 383
Joined: February 11th, 2007, 3:09 am
Location: Box 361 Brielle, NJ 08730-0361

Re: Feedback with 5 minutes Experience of C# Script Engine

Postby joe_blaze » May 22nd, 2014, 11:37 am

Check out the CSE 'transpose' property which the APL+Win programmer can set their preference for implicit (automatic) or explicit (non-automatic) deep transpose of APL+Win arrays passed across the APL+Win and CSE interface.
joe_blaze
 
Posts: 383
Joined: February 11th, 2007, 3:09 am
Location: Box 361 Brielle, NJ 08730-0361


Return to APL+Win & The C# Script Engine

Who is online

Users browsing this forum: No registered users and 1 guest

cron