VTack: A simple language

Version 1.0
Latest APK

This is an interpreter for a simple language which can be used to teach programming to kids. It works on both Android and GNU/Linux.

The language is postscript. It supports functions, local/global variables and run-time constructed code.

In order to run a function, you give the arguments, the function name and a hash sign. For instance:

  100 red#
calls the red function. That function pops one value from the stack and uses it.

Variables can be local or global. When a variable is set in a function, it's created as a local variable. You can then later export it as a global variable using the 'export' builtin:

 {
    200 scale=
    scale export#
 } foo define#

 foo#
In fact, there is no need to set a value first, you can directly export it. The top level (outside of all functions) is considered its own function. Therefore, setting a variable at that level is not considered a global variable export, you need to export it explicitly for that to work. For instance:
  { [Hello name$] print# } greet define#
  "Dodo" name=
  greet#
will not work since 'name' is not exported and the 'greet' function only sees an empty variable.

Setting a variable is done with the '=' operator. Getting the value is done by the '$' operator as demonstrated above.

Here are the drawing primitives:

  N red#
  N green#
  N blue#
     N: 0-100 , sets the intensity of the corresponding
     color channel for the background color.
 
  N width#
     N: 1-30, sets the line width.

  N line#
     draws a line of length N

  D left#
  D right#
     turns D degrees

  N move#
     moves N units without drawing a line

  clear#
     clears the screen

  save#
     saves the current position and heading to a stack

  restore#
     restores the saved position

  N tick#
     delays for N*100 milliseconds (depends on implementation)

  R circle#
     draws a circle with radius R. The center of the circle is
     R units ahead so that the circle intersects the current point.