-
Notifications
You must be signed in to change notification settings - Fork 0
Basic Features
cjkenn edited this page Feb 6, 2021
·
4 revisions
sif supports the following primitive types:
- Numbers. All numbers are represented by the
f64type in rust. Thus, any number if a 64-bit floating point number - Strings. sif strings wrap the
Stringtype in rust. - Boolean. Like strings, bools wrap the
boolrust type.
Variables of these types can be declared using the var keyword:
var str = "string";
var num = 10;
var flo = 10.4;
var b = false;
Arrays and tables are also available. Arrays are really like vectors, and can grow dynamically. Tables are hashmaps, and can also grow dynamically. These can be declared as follows:
var arr = [1,2,3];
arr[0] = 0;
var first = arr[0]; # 0
var tbl = [[
y => "y",
ten => 10
]];
var y = tbl.y; # "y"
if-elif-else structure:
if true || false {
var t = 0;
} elif true && true {
var t = 1;
} elif false || false {
var t = 2;
} else {
var t = 3;
}
for loops:
var g = [1,2,3];
var x = 0;
for idx, val in g {
x = x + val;
}
# x = 6
There is a small stdlib of functions to use in sif. To call a std function, use the @ token:
var x = 10;
@print(x); # 10