Vocabulary#
Every word of the language, and what it means.
The vocabulary of .vis 0.1. The grammar is in Language reference; the normative text in Language specification.
Keywords#
Reserved everywhere: they cannot name anything.
Keyword |
Meaning |
|---|---|
|
declares a numeric constant of the program: param alpha = 0.2 |
|
declares a grid of cells and its channels: canvas plate[256, 256] edge clamp { temperature } |
|
declares the update of every cell of a canvas: kernel diffuse on plate { … } |
|
declares one number over a whole canvas: measure total = sum(t) on plate |
|
the block of commands that runs the simulation, the last part of a program |
|
runs a block of commands n times: repeat 100 { diffuse } |
|
runs a block n times from the same state, with scenario = 0 … n − 1 |
|
writes a channel (.png, .npy, .vti), a whole canvas (.vti) or the series of a measure (.csv) |
|
shows a measure, a summary of a channel or one cell |
|
reads real data into a channel (.npy, .csv, .txt, .asc, .png) |
|
declares an immutable local variable |
|
declares a mutable local variable |
|
runs a block where a condition holds |
|
the alternative of an if |
|
repeats a block for an integer range, both ends included: for i in -1 to 1 { … } |
|
part of for |
|
true when both conditions are |
|
true when either condition is |
|
negates a condition |
|
the true condition |
|
the false condition |
Contextual words#
They have a meaning in one place only; elsewhere they are ordinary names.
Word |
Where |
|---|---|
|
kernel name on canvas, measure … on canvas |
|
for i in a to b |
|
canvas name[w, h] edge clamp |
|
measure … on canvas where condition |
|
load c.t “dem.asc” nodata 0: the value of the cells without data |
|
a channel of 32-bit floats (the default) |
|
a channel of 32-bit integers |
Operators#
From the lowest precedence to the highest.
Operators |
Level |
Meaning |
|---|---|---|
|
1 |
logical or of two conditions |
|
2 |
logical and of two conditions |
|
3 |
logical negation (prefix) |
|
4 |
comparison of two numbers (== and != also of two conditions); does not chain |
|
5 |
addition, subtraction |
|
6 |
multiplication; / is always real division (7 / 2 = 3.5), within 1.15 ULP, with 1 / 0 = MAX, −1 / 0 = −MAX and 0 / 0 = 0; % is the remainder, with the sign of the dividend |
|
7 |
negation |
|
8 |
power, right-associative; x ^ n with an integer literal n ≤ 16 is an exact product |
Compound assignments: +=, -=, *=, /=.
Types#
Type |
Values |
|---|---|
|
a 32-bit floating-point number, always finite: an overflow gives ±3.4028235e38 |
|
a 32-bit integer; arithmetic wraps around (two’s complement) |
|
true or false: the result of a comparison; not a number |
Channel types: f32, float channel (the default); i32, integer channel: exact totals with flux().
Names given by the canvas#
Read-only, inside kernels and measures.
Name |
Value |
|---|---|
|
the column of the cell, from 0, growing to the right |
|
the row of the cell, from 0, growing downwards |
|
the layer of the cell, from 0 (only in a 3-D canvas) |
|
the number of columns of the canvas |
|
the number of rows of the canvas |
|
the number of layers (only in a 3-D canvas) |
|
the index of the scenario inside a scenarios block, from 0; 0 outside |
Edges#
Edge |
Reading outside the canvas |
|---|---|
|
outside the canvas reads the nearest border cell (the default) |
|
outside the canvas reads the opposite side (a torus) |
|
outside the canvas reads 0 |
Reductions of a measure#
Reduction |
Value |
|---|---|
|
the sum of a number over the cells (about 44 bits of precision) |
|
the mean of a number over the cells |
|
the smallest value |
|
the largest value |
|
the number of cells where a condition holds |
Commands of the run block#
Command |
Effect |
|---|---|
|
runs a kernel (one step) or takes a measure (one value of its series) |
|
runs the commands n times |
|
runs the commands n times from the same state, with scenario = 0 … n − 1; not nested |
|
reads real data into a channel |
|
writes a channel: .png (colour map), .npy (raw values) or .vti (VTK) |
|
writes every channel of a canvas into one VTK file |
|
writes the series of a measure |
|
shows a measure (and its distribution over scenarios) |
|
shows a summary of a channel, or one cell |
Files#
load reads .npy, .csv, .txt, .asc, .png; save writes .png, .npy, .vti and the .csv series of a measure.
Limits#
int |
from −2147483648 to 2147483647 |
float |
finite, up to ±3.4028235e38 |
canvas depth |
up to 65535 layers |
nesting |
scenarios blocks do not nest |