the complete frame

The grammar

Vision's grammar is a fixed, small set of frame words. Everything else is names you choose. This page lists all of it.

Naming

Bind a value with is. A constant (something that never changes) uses is always. Names can be reassigned with a fresh is.

a guest is "Marigold"
a limit is always 1000
the limit is the limit plus 1   // error: always-values can't change

Verbs

A verb is introduced with to. Inputs are declared after given, separated by and. The result is handed back with answer.

to advance a phase, given a freq and a rate:
    the phase is the phase plus the freq divided by the rate
    answer the phase

A verb that takes no inputs omits the given clause. A verb that changes its subject uses , changing it.

to reset, changing it:
    the count is 0

The entry point is always to begin:.

Decisions

Branch with if. Add alternatives with or if. The fallthrough is otherwise.

if the total is greater than 0
    say "positive"
or if the total is 0
    say "zero"
otherwise
    say "below zero"

Comparison operators: is · is not · is greater than · is at least · is less than · is one of · is empty

Logic: and · or · not

Repetition

Three forms: iterate a collection, loop while a condition holds, or run a block a counted number of times.

for each item in the items
    say item

while the count is greater than 0
    the count is the count minus 1

repeat 10 times
    add 1 to the tally

for each never uses an index counter. If you need a position, use a separate name and add to it inside the loop.

Failure

Every operation that can fail must be followed by a but if clause. The compiler refuses to build until every failure has a resolution.

read the file at the path giving the contents
    but if it isn't there, say "missing" and stop
    but if it can't be read, explain why and hand it on

Three resolutions are available:

  • stop — handle the failure here; end this path.
  • hand it on — pass the failure to the caller.
  • give up — fatal exit. A last resort.

Absence

A value that might not exist is represented as nothing. Check for it with if there is.

if there is a guest
    say "welcome back"
otherwise
    say "the door is open"