diff --git a/Variable-Definition.md b/Variable-Definition.md new file mode 100644 index 0000000..878bce9 --- /dev/null +++ b/Variable-Definition.md @@ -0,0 +1,33 @@ +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](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 +``` \ No newline at end of file