PLC-lang/rusty

Improved Method/Function value return syntax

開放

#1,094 建立於 2024年2月13日

 (8 則留言) (0 個反應) (0 位負責人)Rust (71 個分叉)auto 404
enhancementgood first issue

倉庫指標

星標
 (351 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

The IEC 61131-3 Syntax for the returned Value from a Method or Function isn't very readable.

The syntax is *functionName* := *Value to Return*

I was actually trying to find the section of IEC 61131-3 that requires this syntax, but I can't seem to find it. I found code examples in the standard that use it, though. Could someone point me to it? I have a copy of the 3rd edition.

My proposal is an alternate syntax that is in line with almost all other modern languages. The system uses "return" as an alias over the function name. This ideal would be an optional syntax to maintain compatibility. return := *value to return*

FUNCTION mySumFunc : DINT
VAR_INPUT
    Blah_Blah1 : DINT;
    Blah_Blah2 : DINT;
VAR_END
return := Blah_Blah1 + Blah_Blah2;
END FUNCTION

This, I think, is much more readable and will also help with implementing Properties. (I will create another feature request for Properties)

Edit:

The new proposed syntax is the following with no := operator

VAR_INPUT
    Blah_Blah1 : DINT;
    Blah_Blah2 : DINT;
VAR_END
  RETURN Blah_Blah1 + Blah_Blah2; 
END FUNCTION```

貢獻者指南