Skip to content
This repository has been archived by the owner on Aug 31, 2024. It is now read-only.

Documentation

Kick de Gans edited this page Mar 11, 2023 · 25 revisions

Documentation for Fusion

1: Basics
2: If statements
3: Loops

1: Basics:

Using the interpreter:

Checking if the runtime is properly installed:

fusion --verify

Opening and running a file:

fusion file.fn

Adding your own libraries:

sudo fusion-packages --add-library <file>

Updating the environment:

sudo fusion-packages --update

Bundle directory of files into easy-to-run "executable" (experimental):

fusion --bundle <directory>

IO:

Printing ASCII text:

print("Hello world!"); /* Print without newline */
println("Hello world!"); /* Print with newline */

User input:

input("Enter your name:"); /* Returns the value the user inputted */

Reading and writing to files:

var file = open("file", options); /* Open file */
read(file); /* Read file */
write(file, "content"); /* Write to file/stream */

Variables:

Declaring variables:

string foo = "bar"; /* String */
int foo = 5; /* Integer */
double foo = 1.23; /* Double */
float foo = 0.45; /* Float */
bool foo = true; /* Boolean */
var foo = value; /* Any type */

Declaring constant variables (Readonly):

const string foo = "bar"; /* String */
const int foo = 5; /* Integer */
const double foo = 1.23; /* Double */
const float foo = 0.45; /* Float */
const bool foo = true; /* Boolean */
const var foo = value; /* Any type */

Declaring public variables (Global):

public string foo = "bar"; /* String */
public int foo = 5; /* Integer */
public double foo = 1.23; /* Double */
public float foo = 0.45; /* Float */
public bool foo = true; /* Boolean */
public var foo = value; /* Any type */

You can also use public const to make a constant public variable

Functions:

Declaring functions:

proc foo() /* No arguments*/
    ...
end
proc foo(bar) /* Arguments */
    ...
end

2: If statements:

if (condition) /* If statement */
    ...
end
else if (condition) 
    ...
end
else
    ...
end

3: Loops:

Normal loops:

while (condition)
    ...
end
until (condition)
    ...
end
dowhile (condition)
    ...
end
dountil (condition)
    ...
end

For loop:

for (int i = 0; i < 5; i = i + 1)
    ...
end

Foreach loop:

foreach (x -> source)
    ...
end
Clone this wiki locally