esolang

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

Expected: Hello, world!

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.

WordDoes
5 'word <>Push a number, the codes of a word, a space
+ - * / mod powPop two, push the result (the lower item is the left side)
++ **Sum or multiply the whole stack
< > <= >= = and orCompare, push 1 or 0
dup swap wover dels topDuplicate, swap, over, clear, push the top index
rangePush every integer between two popped numbers
. drop jump showPrint the top, pop and print, print item n, print the stack
outascii printPrint one character; print the whole stack as text
!n &nStore into or fetch variable n
next back mvMove between stacks, move a value to the next stack
sin cos tan read nilTrigonometry, 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

  1. Print the factorial of 6 with range and **.
  2. Compute (3 + 4) × 5 and print it.
  3. Store 7 in variable 1, then print 7 × 7 using only &1.

Further

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 gecho

Source

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