From 408bbdae81ade41c1d323c52090ba7509ad0e01d Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Tue, 30 Aug 2022 05:53:35 +0000 Subject: [PATCH] Update 'Control Flow' --- Control-Flow.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Control-Flow.md diff --git a/Control-Flow.md b/Control-Flow.md new file mode 100644 index 0000000..9385e7d --- /dev/null +++ b/Control-Flow.md @@ -0,0 +1,39 @@ +ARF has a collection of basic control flow [phrases](Phrases) which are `break`, `next`, +and `return`. Break breaks out of a loop or switch case, next is basically just +a continue statement but using less letters, and a return phrase returns from +the current function. Return phrases are entirely optional and do not take any +arguments. + +ARF also has some control flow phrases that expect an indented block of phrases +under them: + +``` +if condition + something + +if condition + something +else + otherThing + +while condition + something + +switch value +: 324 + something +: 93284 + otherThing +: + defaultThing + +for index:Size element:Int someArray + something +``` + +These do what you'd expect them to, but for loops in ARF need some further +explanation. Many modern languages allow you to iterate over data, and ARF is no +exception. The first [argument](Arguments) of a for loop must be an index of type `Size`, the +second argument must be typed as an element of the third argument, which must +be an array or inherit from an array. In the future there might be some +iterateable [interface](Interface-Definitions) that an object could fulfil. \ No newline at end of file