In a language such as *MatLab*, this is handled elegantly in the
language. One can write `A[:,2:3] = 1`, and the second and
third columns of the `A` matrix will be assigned the value 1.

But what should we do in this virtual-machine-reflecting language ? It would be nice to represent everything like opcodes: An instruction, and a set of arguments. An opcode could be introduced to ``cut'' out the block we want to work with, assign it to some variable, and when we're done working on the variable we could call another opcode to have the results ``pasted'' in again.

That would not just be ugly, it would also be inefficient, since it would involve a larger number of opcodes which in turn would impose a greater overhead in the execution of the program. So that's not the way it is done.

Even though we do not allow normal mathematical expressions to be used
as arguments to opcodes (e.g. you cannot enter `add r0, r1*8`),
indexing has been implemented as a sort of ``modifiers'' to arguments.
The second and third columns of a matrix register `r0` can be
assigned the value 1 with the following instruction: `move
r0[:][1:2], 1`. This changes the way the virtual machine sees and
treats the first argument to the `move` opcode. Instead of the
first argument being a register (as it would be without the indexing),
it is now an *indexing*. The base variable of the indexing is
the register `r0`, and the indexing consists of two intervals,
one (the `[:]` index) which is a ``full'' interval (one that
resolves to the full length possible in the given base variable), the
second which is a bounded interval (a block bounded by a lower and
upper index value) resolves to the integer interval .
We use
zero-based indexing, so `r0[:][1:2]` refers to the second and
third column of `r0`. Optionally, one can also specify a step
value, for example `r0[0:5:50]`, which refers to the elements
at positions
of the register `r0`.

A small program demonstrating this indexing could be:

;; ;; Indexing example ;; entry "indexing" decl matrix zero r0, 10 move r0[3:6][3:6], 1 move r0[:][0], 2 move r0[:][9], 3 move r0[0][:], 4 move r0[9][:], 5 return r0 end

This is also a simple example showing how dimensions of variables
(registers) can change dynamically at run-time. The `decl`
opcode only tells the virtual machine that `r0` is a
matrix. The `zero r0, 10` opcode initializes `r0` with a
matrix holding zeros.

It returns the matrix

(3.1) |