Update 'Functions and Methods'

Sasha Koshka 2022-08-24 16:35:09 +00:00
parent 3e2d5984bb
commit 09f0bfcde1

@ -1,15 +1,19 @@
Functions are written like this: # Syntax
``` ```
func ro someFunction func ro someFunction
@ reciever:SomeObject
> input:Int > input:Int
< output:Int:mut < output:Int:mut
--- ---
somePhrase somePhrase
``` ```
The first part of the function's content is its inputs and outputs. A function Function sections are divided in two. The first part can contain inputs, outputs, and a method reciever. Inputs are preceded by a '>', outputs are preceded by a '<', and the method reciever is preceded by a '@'. Function outputs can have default values, whether they be simple or complex.
may have any number of these, and they act as local variables. Function inputs
The latter part contains the actual code of the function, which is composed of [phrases](Phrases).
# Semantics
A function may have any number of inputs and outputs, and they act as local variables. Function inputs
must always be immutable, and function outputs must always be mutable. must always be immutable, and function outputs must always be mutable.
The second part is the actual code of the function. It is separated from the The second part is the actual code of the function. It is separated from the