L1VM - immutable
L1VM - immutable
I did add two new compiler flags:
(variable-immutable)
(variable-mutable)
If the first is set then all following variables defined by set
are immutable by default.
To switch of this you need to use the second one.
Here is a small demo program (hello-mut.l1com):
// Brackets - Hello world!
// set variables default as immutable
// change setting by: (variable-mutable)
//
#include <intr.l1h>
(main func)
// all default variables are immutable after this is set!
(variable-immutable)
// immutable:
(set int64 1 zero 0)
(set int64 1 x 23)
(set int64 1 y 42)
// mutable:
(set mut-int64 1 a 0)
// string always mutable!
(set string 13 hello "Hello world!")
// print string
print_s (hello)
print_n
((x y *) a =)
print_i (a)
print_n
exit (zero)
(funcend)