Page 1 of 1

CSE: Unexpected errors

PostPosted: September 18th, 2016, 9:12 am
by Ajay Askoolum
I am using V16.1 (installed using the updater).

I am encountering unexpected errors: see attached WMV.

My code is:
Code: Select all
      ⎕cself←'c' ⎕cse 'Init' 'System'
⍝ Issue 1:
      ⎕cse 'Exec' (⍉,[⍬]"public static int myAge {{} get; set; {}};")
      ⎕cse 'GetLastError' ⍝ NOTE/QUERY Why is the terminating semi-colun an error?
      ⎕cse 'Exec' (⍉,[⍬]"public static int myAge {{} get; set {}}") ⍝ It works without te semi-colun
      ⎕cse 'SetValue' 'myAge' '42'
      1.25 × ⎕cse 'GetValue' myAge'
⍝ Issue 2:
      ⎕cse 'Exec' (⍉,[⍬]"public static int myAge2 {{} get; set; {}} = 42") ⍝ NOTE: No ; BUT default Value specified
      ⎕cse 'GetLastError' ⍝ Why is this an error? [NOTE error - property is of type int]
⍝ Issue 3:
      ⎕cse 'Exec' (⍉,[⍬]"public static string myName {{} get; set; {}}") ⍝ Omitting the semi-colum to avoid a repeat error
      ⎕cse 'SetValue' 'myName' 'Ajay'
      ⎕cse 'GetLastError' ⍝ ⍝ Why is this an error? [NOTE error - property is of type string]

      ⍝ Works for variables
      ⎕cse 'ExecStmt' 'public string thisName;'
      ⎕cse 'SetValue' 'thisName' 'Ajay'
      ⎕cse 'GetValue' 'thisName'
⍝ Summary:
⍝ 1. Why is the ternminating semi-colon an error? Note - the statement is valid in VS2015.
⍝ 2. Why can't I set a default value for a public property?
⍝ 3. Why can't I assign to a property of stype string?

Re: CSE: Unexpected errors

PostPosted: September 18th, 2016, 2:34 pm
by Ajay Askoolum
Apologies: the property definition terminating with semi-colon is an error (in VS 2015) unless a default value is specified. Please ignore the first question.

Re: CSE: Unexpected errors

PostPosted: September 29th, 2016, 2:40 pm
by joe_blaze
We will research your questions are report back when we have results of that research.

Re: CSE: Unexpected errors

PostPosted: September 29th, 2016, 2:58 pm
by joe_blaze
Have you seen this: http://stackoverflow.com/questions/4691888/automatic-property-with-default-value. It appears that the 'automatic property definition' syntax may not support default values and that a 'backing' variable may be needed. Where did you obtain the syntax "public static int myAge2 {{} get; set; {}} = 42"?

e.g.:

private int m_HowHigh = 5;
public int HowHigh
{
get { return m_HowHigh; }
set { m_HowHigh = value; }
}

Re: CSE: Unexpected errors

PostPosted: September 29th, 2016, 3:01 pm
by joe_blaze
On the other question, the issue appears to be related to the 'static' keyword, although I don't yet understand the CS0266 error code which the C# compiler is returning


⎕cse 'ExecStmt' 'public string myName{get;set;}'
0
⎕cse 'SetValue' 'myName' 'Joe'
0
⎕cse 'ExecStmt' 'public static string myName2{get;set;}'
0
⎕cse 'SetValue' 'myName2' 'Joe'
¯1

⎕cse 'GetLastError'
(1,11): error CS0266: Cannot implicitly convert type 'object' to 'string'. An ex
plicit conversion exists (are you missing a cast?)

⎕cse 'ExecStmt' 'myName2 = myName;'
0
⎕cse 'GetValue' 'myName2'
Joe

Re: CSE: Unexpected errors

PostPosted: September 29th, 2016, 4:57 pm
by Ajay Askoolum
My code above has managed to acquire stray curly brackets; apologies.
It appears that the 'automatic property definition' syntax may not support default values and that a 'backing' variable may be needed.
That is definitely not the case and neither is a backing variable required. You could try out the code in Visual Studio - the project is in PROOF.ZIP which is attached. For convenience here's the code:
Code: Select all
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PROOF
{
    class Program
    { // Trying it in VS2015
        public static int myAge2 { get; set; } = 42;
        public static string thisName { get; set; } = "apl2000";
        static void Main(string[] args)
        {
            Console.WriteLine("Writing Defaults:");
            Console.WriteLine("muAge2 = {0} thisName = {1}",myAge2,thisName);
           
            Console.WriteLine("Overwriting Defaults:");
            myAge2 = 42 + 42;
            thisName = "APL LLC";
            Console.WriteLine("muAge2 = {0} thisName = {1}", myAge2, thisName);
            Console.ReadLine();
        }
    }
}
As you can see both the int and string properties have a default value and I can simply override them.

Alternatively, you could simply run \C#\VS2015\PROOF\PROOF\bin\Release\PROOF.exe from the location wherein you have extracted the files from the ZIP.

[]cse does NOT allow the default values. With the string property, I get the error you show:
Code: Select all
 Œcse 'SetValue' 'thisName' 'apl2000'
CSE ERROR: (1,12): error CS0266: Cannot implicitly convert type 'object' to 'string'. An explicit conversion exists (are you missing a cast?)
I think I should be able to assign to a string property in the same manner as I can assign to a string variable.

Re: CSE: Unexpected errors

PostPosted: September 30th, 2016, 2:44 am
by joe_blaze
The error messages received come directly from the C# debugger or compiler and not APL+Win, so it may be that the operations you want to perform, which are available in the version of Visual Studio you are using, may not be available in the Dynamic Language Runtime used by the CSE. What is the version of Visual Studio you are using?

Re: CSE: Unexpected errors

PostPosted: September 30th, 2016, 6:00 am
by Ajay Askoolum
I am using Visual Studio 2015 Enterprise. The project uses .Net Framework 4.6.1.

I realize that the error is coming from c#.

I understand that CSE is also using framework 4.6.

[]cse 'ExecStmt' 'string myVariable;'
[]cse 'SetValue' 'myVariable' 'new value'

In the latter statement, there must be something that is permitting 'new value' to make its way from APL+Win to the C# debugger/compiler' successfully. The same thing is required for string properties, I believe.

There is no issue with int properties.

As regards the default value for properties, my guess is that []cse must be validating the statement and validating the syntax - ensuring that there is NO trailing semi-colon. When you specify a default value, there is a terminating semi-colon.

Re: CSE: Unexpected errors

PostPosted: September 30th, 2016, 11:55 am
by joe_blaze
Actually all validation of a C# statement is done by the C# parser, debugger or compiler and not by APL+Win, so there is still some investigation to be done, but that will take more time.

Note the difference with a static or non-static string property - that is what will need further checking.

⎕cse 'ExecStmt' 'public string myName{get;set;}'
0
⎕cse 'SetValue' 'myName' 'Joe'
0 <---- non-static string property successfully set
⎕cse 'ExecStmt' 'public static string myName2{get;set;}'
0
⎕cse 'SetValue' 'myName2' 'Joe'
¯1 <---- stati string propery not successfully set

Re: CSE: Unexpected errors

PostPosted: October 1st, 2016, 2:53 am
by Ajay Askoolum
Thank you. It is interesting that a static variable does NOT have the same issue.
Code: Select all
      ⎕cse 'ExecStmt' 'static string qw;'
0
       ⎕cse 'SetValue' 'qw' 'ajay askoolum'
0
      ⎕cse 'GetValue' 'qw'
ajay askoolum
I'll await the results of your investigation
1. Why does the assignment to a static string property fail?
2. Why does []cse not permit default values for properties, static or non-static?

What is the compiler version used by []CSE? Is it:
Code: Select all
Compiler version 4.0.30319.17929
or later? This or earlier versions appear to have the same problem.
You may be interested in this:

Re: CSE: Unexpected errors

PostPosted: October 13th, 2016, 3:56 am
by joe_blaze
Hi Ajay:

Here is a way to do what you request:

⎕cself←'c1'⎕cse 'Init' 'System'
⎕cse 'ExecStmt' 'using System;'
0
⎕cse 'ExecStmt' 'public static string s3 {get;set;}'
0
⎕cse 'ExecStmt' 's3={0}' '"s3"'
0
⎕cse 'GetValue' 's3'
s3

The syntax for the default value of a property without a back property, will require updating the CSE to a newer version of the Microsoft Roslyn C# compiler. We are examining that possibility.