From 2e8c99764f6acace4219894fa4262a232ed07f2b Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Wed, 24 Aug 2022 05:45:14 +0000 Subject: [PATCH] Update 'Variable Definition and Type Notation' --- Variable-Definition-and-Type-Notation.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Variable-Definition-and-Type-Notation.md diff --git a/Variable-Definition-and-Type-Notation.md b/Variable-Definition-and-Type-Notation.md new file mode 100644 index 0000000..135f73a --- /dev/null +++ b/Variable-Definition-and-Type-Notation.md @@ -0,0 +1,13 @@ +In ARF, variables are defined using the syntax `name:Type:qualifier`, where name +is a name token and type is either just a name token describing what type it is, +or a pointer to a value of that type or an array to a value of that type. The +only supported qualifier is `:mut`, which marks the variable's data as mutable. +Variables are immutable by default. + +Pointers are defined like `name:{Type}` and arrays are defined like +`name:{Type length}` where length is an unsigned integer literal or an ellipsis +token (..). If an integer token is given, the length of the array is static, and +if an ellipsis is given, the length is dynamic and can be changed at runtime. + +Variables can be defined wherever they are used. For example, `set x:Int 5` +defines a variable of type Int and sets it to 5. \ No newline at end of file