Fash
Not to be confused with Bash
Fash is a language where the code looks like console commands, and variables use the directory structure. The word 'Fash' is a fusion of the words 'False Bash'.
Variables
Fash has a unique way of using variables, where every variable is a file in root or a subfolder. The extension dictates the variable type, using:
File extension | Variable type |
---|---|
.int | Integer |
.uint | Unsigned integer |
.bool | Boolean |
.char | Character |
.float | Float |
.*.arr | Array of type * |
.str or .char.arr | String |
.any | Any type |
.null | Null variable |
.*.ptr | Pointer to variable. |
Where the name of the file is the name of the variable. Using this, variables can have multiple types. You are allowed to use subfolders for variables. Variables in ./local are only usable by the subroutine that writes to them, ./temp are reset when you leave the subroutine, no matter what, and ./args are defined when a file/function/macro is run/called. In ./args, file names need to go in numerical order from 0. You are not allowed to step out of root.
RAM variables
RAM variables are a special kind of variable, that allow you to store values from files to use them. There are 8 of these, named RAM0 through RAM7. You do not have to use Read or Write to use them.
Subroutines
Fash has 2 types of subroutine: macros and functions. Macros are substituted in when running, and functions are jumped into and out of. Macros can use ./local variables from where they are run, but cannot have their own local variables. You can define macros and functions in .fashm and .fashf files, respectively. You are allowed to reference a function inside itself, in fact it actually has a special name: ./~.
Basic subroutines
Fash has a few basic subroutines that can be used, which can be run without a ./:
Function name | Function use |
---|---|
Return | Returns from a function. Can only be used in .fashf files. |
Prints to the screen. | |
Get | Gets user input |
Read | Get a variable from a file and store in a RAM variable. |
Write | Get a variable from a RAM variable and store it in a file. |
Run | Runs a .fashm or .fashf file and store return in a RAM variable. |
Jump | Jump to a specified line in the program. Second argument is condition. |
Skip | Jumps over the next line in the program if the condition is true |
Err | Throw error. |
Comment | Ignore line. Does count toward line total though. |
.fashp and .fashl
If you zip a folder, and rename it .fashp with a main.fash, or rename it to .fashl with at least one .fashf or .fashm, you create a standalone file or function library. You can enter a function library like normal with Run ./lib.fashl/fib.fashf RAM1 4 running a fib function from the lib library with an argument of 4 and storing the result in RAM1.
Examples
Recursive fibonacci function
dir: / ├ fib.fashf └ /args └ 0.uint fib.fashf: READ ./args/0.uint RAM0 JUMP 6 RAM0=0 JUMP 6 RAM0=1 RUN ./~ RAM1 RAM0-1 RUN ./~ RAM2 RAM0-2 RETURN RAM1+RAM2 RETURN 1
Truth machine
dir: / └ main.fash main.fash: GET RAM0 PRINT RAM0 JUMP 1 RAM0=1
Tetrate
dir: / ├ main.fash └ /args ├ 0.uint └ 1.uint main.fash: READ ./args/0.uint RAM0 READ ./args/1.uint RAM1 SKIP RAM1>0 RETURN 1 READ RAM0 RAM2 READ RAM1 RAM1-1 READ RAM0^RAM2 RAM2 JUMP 5 RAM1>=1 RETURN RAM2