plxvm/doc/data.md

1.5 KiB

Data and Expression

There are constants (provided by the host application), global and local variables, scalar variables (data type number_t), numeric arrays (element data type number_t), and strings (element data type int8_t). Global variables are stored on the heap, wheras local variables are stored on the data stack.

Scalar and string global variables can be explicitly defined and allocated using the var statement or by assigning a value. Not allocated variables may not be used in expressions. Array variables must be defined by using the var statements as well as local variables by using the var* statement.

Expressions with infix notation are compiled into stack operations with post-fix operations, preserving operator bindings.

Statement Description
var a,b(20),c$,d$(10) Definition and allocation of scalar (a), array (b), string (c), and string with length (d) variables.
var* a,b,c Definition of local variables (on stack)
const a=n,b=n,c=n Definition of constant values (on heap, but read-only, only numbers or characters n can be assigned)
x=ε Assignment of value to variable x (with allocation if not already defined)

Operators

Operators Description
+ - * / mod Arithmetic infix operations
< > <= >= Relational infix operations
and or not Logical and Boolean infix and prefix operations
$var Address of variable (postive: heap: neagtive: data stack)
var$ String variable
x(i) Array selector (first index is 1)