It could be just me not being able to find stuff, but there does not appear to be an explanation for the "AUTO" addition in the X# documentation. For example:
Kees,
AUTO means that the compiler will AUTOmatically create a backing field for the property and the matching Getter and Setter.
I will check the docs and add a description.
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
Another thing. It is not really "the documentation" but still a valuable source of information: the docs.xsharp.it website. On the page https://docs.xsharp.it/doku.php?id=code ... e&s[]=auto is an example that does not work. There is a compilation error on the line "return nResult": "Error XS0126 An object of a type convertible to 'int' is required". Strange thing is of course that nResult is actually an INT. When I remove the LOCAL and do it as follows:
Here it says "AS INT" but further down it says "Returns: A Logical value" (there is also a typo there). So could it be that the compiler thinks this method will return a logical instead of an int?
Kees,
The compiler knows that it is an int.
What you see in this tooltip is coming from the XSharp.RT.Xml file.
That file is generated from documentation comments, and is apparently not correct.
And w.r.t. that website: that website is maintained by Wolfgang. We have no control over that
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
If the compiler knows that CompareTo() returns an INT then I do not understand why I get a compilation error in the code below at the line "RETURN nResult":
FUNCTION TestDelegate() AS VOID
LOCAL oPersons AS List<Person>
LOCAL cText AS STRING
oPersons := List<Person>{}
oPersons:Add(Person{"Robert"})
oPersons:Add(Person{"Fabrice"})
oPersons:Add(Person{"Chris"})
oPersons:Add(Person{"Nikos"})
oPersons:Sort( ;
DELEGATE(o1 AS Person, o2 AS Person) {
LOCAL nResult AS INT
nResult := o1:Name:CompareTo(o2:Name)
RETURN nResult
};
)
cText := ""
FOREACH Ps AS Person IN oPersons
cText += Ps:Name + CRLF
NEXT
MessageBox.Show(cText)
RETURN
CLASS Person
PUBLIC PROPERTY Name AS STRING AUTO
CONSTRUCTOR(cName AS STRING)
SELF:Name := cName
RETURN
END CLASS
The error is: "Error XS0126 An object of a type convertible to 'int' is required", at the line "RETURN nResult". Surely this RETURN is for the DELEGATE function? Yet if I change the return type of TestDelegate() to AS INT instead of AS VOID (and also change the single RETURN to RETURN 0), the compiler error is gone and the code works. It makes no sense to me.