Gecho
A small Forth-like calculator named after a typo: its author meant to type "echo".
Max Bernstein (Tekknolagi), 2011 · Turing complete: no · ●○○ easy · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
Max Bernstein (Tekknolagi) wrote gecho in the summer of 2011, inspired by Forth. The name is a typo for "echo", and the specification asks for a lowercase g. A program is a list of words separated by spaces. Numbers push themselves, and every other word works on the stack.
Read the story
Gecho is a simple first stack language. It has no loops or conditionals; the specification lists them as future syntax. So every program runs straight through and stops. That makes it total, not Turing complete. What it does have: whole-stack folds (++ sums everything, ** multiplies everything), numbered variables, and a ring of stacks you can step through.
The machine
A ring of stacks of numbers, numbered variables, and a few modes. An empty stack pops as 0.
| Word | Does |
|---|---|
5 'word <> | Push a number, the codes of a word, a space |
+ - * / mod pow | Pop two, push the result (the lower item is the left side) |
++ ** | Sum or multiply the whole stack |
< > <= >= = and or | Compare, push 1 or 0 |
dup swap wover dels top | Duplicate, swap, over, clear, push the top index |
range | Push every integer between two popped numbers |
. drop jump show | Print the top, pop and print, print item n, print the stack |
outascii print | Print one character; print the whole stack as text |
!n &n | Store into or fetch variable n |
next back mv | Move between stacks, move a value to the next stack |
sin cos tan read nil | Trigonometry, read numbers, do nothing |
Example
'Hello, pushes the six character codes and <> pushes a space.
'Hello, pushes the six character codes and <> pushes a space. 'world! pushes six more, and print empties the stack from the bottom up as text.
Patterns it teaches
- Stack machines: the plainest kind, a list of words over a stack.
- Concatenative: a program is words in a row; join two programs and you get one that does both.
Try this
- Print the factorial of 6 with
rangeand**. - Compute (3 + 4) × 5 and print it.
- Store 7 in variable 1, then print 7 × 7 using only
&1.
Further
See also
Stack-based
Write your own in Run Convert a program from Gecho
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: gecho.
Command line
shib run gecho -e '5 1 range ** .'shib manual gechoSource
- Module
langs/stack/ports.js- Interpreter
langs/stack/gecho.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org