Gecho

The gecho programming language is often referred to without a capital 'g', and was created by Max Bernstein ( User:Tekknolagi ) in summer of 2011.

Inspiration
This language was inspired by FORTH. It is stack-based.

Naming
This language was named after a typo by the author. He "meant to type 'echo' but wrote a 'g' in front by accident."

Commands
NOTE: gecho does not by default display the result of the operation! One must use `.`

 + Pops two elements from the stack, adds them together, and pushes the result.  ++ Pops all the elements from the stack and adds them together; pushes result.  . Prints the top element in the stack.  * Pops two elements from the stack, multiplies them, and pushes the result.  dels Pops all elements from the stack.  show Pretty prints the stack.  dup Pushes a copy of the top element of the stack.  swap Pops two elements from the stack, and pushes back in each other's places. </li> - Pops two elements from the stack, subtracts the upper from the lower, and pushes the result. </li> jump Pops an element from the stack (a) and prints stack[a] </li> range Pops two elements from the stack (a, b) and prints range(b, a); starts at b, increments by one until a, pushes the array onto the stack. </li> [num] Pushes `num` to the stack. </li> ** Pops all the elements from the stack and multiplies them; pushes result. </li> ![tapeindex] Pop element from stack; set variables[tapeindex] to popped value. </li> &[tapeindex] Push variables[tapeindex] to the stack. </li> wover a = pop; b = pop; push(b); push(a); push(b); ( a1 a2 -- a1 a2 a1) </li> drop Pop top element from stack, show value. </li> pop see `drop` </li> top Push the index of the top of the stack to the stack. </li> outascii Pop top element of stack and print ASCII character that corresponds to decimal. </li> print Pop all elements of stack and prints ASCII characters that correspond to decimal. </li> / Pop top two elements from stack; divide lower element by upper element. </li> @[mode] Toggles mode specified. </li> mode Prints a list of all enabled modes. </li> <li>modes Prints all modes, complete with 'enabled' flag. </li> <li>tot For use with @tracker. Prints number of commands so far. Does not count as a command. </li> <li>reset Resets the command count. For use with @tracker. Does not count as a command. </li> <li>tan Pops one element from the stack (degrees!) computes tan(x) </li> <li>sin Pops one element from the stack and computes sin(x) </li> <li>cos Pops one element from the stack and computes cos(x) </li> <li>pow a = pop; b = pop; push(b^a); </li> <li>mod a = pop; b = pop; push(b%a); </li> <li>read Reads user input. Only really useful with file reading/compiling. Pops one element from the stack and reads that number of numbers, and pushes them to the stack. </li> <li>< b = pop; a = pop; push(a < b); </li> <li>> a > b </li> <li>>= a >= b </li> <li><= a <= b </li> <li>= a == b </li> <li>'[word] Push each character of onto the stack. </li> <li><> Push ' ' to the stack. </li> <li>and Push a && b to the stack. </li> <li>or Push a || b to the stack. </li> <li>nil Does absolutely nothing. </li> <li>next Cycles through the stacks. If on stack 1, will move to stack 2. </li> <li>back Does the opposite of `next`. </li> <li>mv Moves the top element from the current stack to the next stack. To COPY, use `dup mv`. </li> </ol>

Turing completeness
It is not yet Turing complete.

Hello World
'Hello, <> 'world! print

Limited Fibonacci
0 1 dup wover + dup wover + dup wover + dup wover +

Factorial
5 1 range ** Pushes the numbers 1 through 5 onto the stack, and then multiplies them all.

Multiple Stacks
1 2 + show next 3 4 + show Computes 1+2, shows it, moves to the next stack, computes 3+4, and shows it.

See `mv` on how to exchange information between stacks.

Loops
5 0 [ i ] This pushes 5 and 0 to the stack, and then iterates from 0 to 5. `i` pushes the counter to the data stack each iteration. Fibonacci in a loop: 0 1 10 0 [ dup wover + ] Iterates from 1 to ten, calculating 10 fibonacci numbers.

If Statements
if { 2 3 < ; 1 + ; 1 - } If `2<3`, it adds one to the top of the stack. Otherwise, it subtracts one.

Function definitions
@sayhi { 'hello <> 'world print } Stores the body into the function `sayhi` and whenever `*sayhi` is seen, it calls `sayhi`. Uses the stack for arguments. @add { + } Takes two arguments from the stack, adds them, and pushes the result.

Downloadable
Its original implementation (and current implementation) can be found at.

Online Interpreter
One can experiment with gecho in an online interpreter at.