Syntax
Syntax Examples
Modules and Imports
- To import a module, use the
import
keyword followed by the modulefilename
,standard library name
, or aURL
.
import "./module";
import "std:math";
import "http://example.com/module.ext";
Variables
- To declare a variable, use the
let
keyword followed by the variable name.
let name = "Extron";
let x = 12;
let y = [1, 2, 3];
- To re-assign a value to a variable, use the
set
keyword followed by the variable name.
set name = "Hello Visitor";
set x = 1;
Functions
- All functions must be assigned to a variable. To declare a function use the
fn
keyword.
let add = fn(a, b) {
a + b;
};
print(add (1, 2));
Console
3
Conditional Statements
- To create a conditional statement, use the
if
keyword followed by the condition.
let x = 10;
if (x > 5) {
print("x is greater than 5");
} else {
print("x is less than or equal to 5");
}
Console
x is greater than 5
Loops
- To create a loop, use the
loop
keyword followed by the loop condition. Use thebreak
keyword to exit the loop.
let i = 0;
loop {
if (i > 2) {
break;
}
let a = ["a","b","c"];
print(a[i]);
set i = i + 1;
}
Console
a
b
c
Type Checking
- To check the type of a variable, use the
typeof
keyword followed by the variable name.
let x = 10;
print(typeof x);
Console
number
Comments
- To create a single-line comment, use the
//
symbol.
// This is a single-line comment