1 Variable Definition
Sasha Koshka edited this page 2022-09-19 05:18:02 +00:00

In ARF, global variables are defined using data sections. However, local variables are defined whenever there is a declaration. Declarations consist of a variable name, a colon, and a type specifier.

x:Int

x:Int:<5>

x:Obj:(
	.pv this:Int
	.pv that:Int)

Everything follows a pattern of definition -> instantiation. Variables are defined by defining their type and initial value using a type specifier, and they are instantiated at that point in the code. Wheverever in a phrase a variable can be used, it can be defined.

It is very useful to define a variable's value based on the return value from a function call. For this purpose, return direction is used.

To define a variable normally, a let phrase is used.

let x:Int:<5>

Multiple variables may be defined in a single let phrase.

let x:Int y:Int z:Int

You can even define a variable as an argument to a function.

file.read buffer:Byte:16 -> amountRead:Size error:Error