Defined function (traditional): Difference between revisions

Jump to navigation Jump to search
Line 26: Line 26:


== A+ ==
== A+ ==
[[A+]] uses a reworked syle of function and operator definition than maintains the principle of a header that matches the way the function will be used, but differs in many details:
[[A+]] uses a reworked style of function and operator definition than maintains the principle of a header that matches the way the function will be used, but differs in many details:
* The result name is not included in the header; instead, the result of the last executed statement is returned (and so [[niladic function]]s cannot be defined).
* The result name is not included in the header; instead, the result of the last executed statement is returned (and so functions that do not return a result cannot be defined).
* The header is separated from the body with a colon, and the body of a multi-line function is enclosed in curly braces.
* The header is separated from the body with a colon, and the body of a multi-line function is enclosed in curly braces.
* Functions have lexical scope. Variables assigned are local by default, and can be made global by enclosing their names in parentheses when assigning.
* Functions have lexical scope. Variables assigned are local by default, and can be made global by enclosing their names in parentheses when assigning.

Navigation menu