Introduction to Var'aq Programming

This Site is intended to provide helps to Var'aq language programmers around the world through technical examples, informational articles, and personal assistance.

The following examples are meant to be a quick Getting Started sort of tutorial using the varaq-kling.pl version in Perl.

Example 2. Arithmetic
Since Var'aq is a stack-based programming language like FORTH, arithmetic is performed using Reverse Polish Notation (RPN) which uses post-fix operators. Using post-fix notation means that the arithmetic operator appears *after* the numbers on which it operates.

Basic (infix notation):
PRINT 2 + 2
Lisp (prefix notation):
(print (+ 2 2 ) )
FORTH (post-fix notation):
2 2 + .
Var'aq (post-fix notation):
2 2 boq cha'

Because of the nature of post-fix notation, normal arithmetic order of precedence is not handled by the programming language--the programmer must ensure the order of precedence himself.

Basic (automatic order of precedence):
PRINT 2 + 5 * 2
Multiplication will happens first (5 * 2)=10, then 2 + (10).
Lisp (prefix notation):
(print (+ (* 5 2) 2 ) )
Multiplication will happens first (5 * 2)=10, then 2 + (10).
FORTH (programmer-controlled order of precedence):
2 5 2 * + .
The last 2 is multiplied times the 5 giving 10, then the 10 and first 2 are added together.
Var'aq (programmer-controlled order of precedence):
2 5 2 boq'egh boq cha'
Same as FORTH example above.

See the Var'aq specification for the arithmetic operators supported by Var'aq.

Go back to go to the next example.

©Copyright 2004, Mr. Merrick J. Stemen. All rights reserved.