1: #line 111 "./lpsrc/flx_tutorial.pak" 2: #import <flx.flxh> 3: val i = 40; 4: val j = 2; 5: val k = i + j; 6: print k; print "\n";
Notice you did not have to declare the type of the values. This is called 'type inference': the compiler works out the type from the initial value for you. You can declare the type of a variable if you want: the following program is equivalent to the one above:
1: #line 130 "./lpsrc/flx_tutorial.pak" 2: #import <flx.flxh> 3: val i : int = 40; 4: val j : int = 2; 5: val k : int = i + j; 6: print k; print "\n";
Values are constants: they cannot be modified, and, as we will see later, they cannot be addressed. This means the compiler is free to load the value into a register or perform other optimisations (including elide the storage for the value entirely).
There is a shortcut form for declaring variables using the := operator:
1: #line 150 "./lpsrc/flx_tutorial.pak" 2: #import <flx.flxh> 3: a := 1; 4: b:int := 2; 5: 6: c:int,(d,e) := 3,(4,5); 7: 8: print a; print " "; 9: print b; print " "; 10: print c; print " "; 11: print d; print " "; 12: print e; print " "; 13: endl;