Open TheColonel2688 opened 8 months ago
Note: I can't try most of the code I write in Rusty because it is all Object Oriented and uses Interfaces and Properties.
I edited the issue text and changed the proposed improved return syntax to match what was discussed in #1094
Properties are not part of the IEC 61131-3 Standard but are heavily used in Codesys and Codesys derivatives (Beckhoff etc).
I would argue they should be in the standard, but the standard is also pretty outdated and is slowing down the evolution of the Automation Software Industry.
If RuSTy wants to be compatible with Codesys, it needs Properties. VAR_INPUT and VAR_OUTPUT can't be added to Interfaces. Only Methods Declarations/Prototypes can be added. Properties are heavily used with Interfaces to allow for Polymorphism with data, and not just Methods.
Codesys does not have a Text-Only format defined for properties (as far as I know), so this is where it gets tricky, as RuSTy needs to define its own Text-Only format.
Edit: It sounds like Codesys Go! will have a Text Only format for all Structure Text, and such it will have a Text Only format for Property, but that format hasn't be published yet. End_Edit
This is one option for a text-only format
Get and Set are Special Methods. In codesys, the Value passed to a Set Method is accessed by using the Propertry's Name, and the Value to return from a Get Method is also the Propertry's Name.
Problem: This is a bad syntax because it can accidentally be reversed;
This is compile-able (but nonsensical)
This is also compile-able (not actually performing a get)
This is also compile-able (not actually performing a set)
The previous syntax should be allowed for compatibility with Codesys, but an alternate form should be allowed and should be the official syntax for RuSTY. This is how C# handles properties, and since many Codesys/Beckhoff Developers are also C# devs, it will feel natural.