Variables

Source: reference-book. Raw markdown: /raw/docs/reference-book/Variables.md

Variables are event markers, not memory owners. They only become active when event reaches them. variables are fixed parts of your program's structure.

Use <<<$>>> before an identifier to make it a variable,

"Hello World!" $myFirstVar
myFirstVar ?

In the above example the value literal <<<Hello World!>>> is representing our initializer event and it is triggered as soon as our application starts. Events always flow left to right.

Value Literals

Simorg's runtime infers the type and runtime doesn't need any type definition.

FormExampleMeaning
Buffer<<<0x01>>>raw bytes (hex)
Number<<<10>>>integer or decimal
String<<<"Hello">>>text

###Empty Values are valid Events — they represent emptiness, not null or void,

0      // empty number
0.0    // empty decimal
0x     // empty buffer
""     // empty string

Doing a truthy check of empty values is equivalent to <<<false>>>. This topic will be discussed later under <<<Event Flow>>> section.

Simorg doesn't have any concept related to nullity e.g. <<<undefined>>>, <<<null>>>, <<<nil>>>, <<<Option>>>, <<<Maybe>>> and others.

Escape sequences including, <<<\n>>> (newline), <<<\r>>> (carriage return), <<<\t>>> (tab) are supported inside String values.

It's also possible to insert a value into a string using <<<{}>>> placeholder

100 "number {} is now embedded" ?

Using <<<>>> before <<<{}>>> will disable this behavior.