# Flatland

Jump to navigation
Jump to search

The **Flatland** language operates on a 2D plane of instructions, but it is *not* grid-based (as opposed to Befunge and ><>). Rather, the execution paths are defined by geometric shapes, namely infinite lines and circles.

Inspired by ASCII-Only's chat message in PPCG.SE chat room:

*possibly*lines could be execution paths, and points and circles used to indicate control structures/literals.*possibly*

## Synopsis

- A program consists of a set of points, lines and circles.
- Each point contains an instruction.
- A line represents a sequential execution path.
- A circle represents a loop.
- There is one instruction pointer (IP), moving along the specified lines and circles.
- An intersection represents a conditional; the IP transfers to another path if a certain condition is met.

## Details

- The language is stack-based, and the instruction set (likely) resembles one of Befunge or ><>, except the routing commands.
- Points are defined by (x,y) coords.
- Lines are defined by two points on it.
- Circles are defined by its center and radius.
- Point-on-line relationships are automatically detected with a tolerance value.
- When the program starts, IP is at the first point specified, facing positive X direction (if ambiguous, positive Y).
- The program terminates when the IP is on a line and no more points are left in the current direction.
- On an intersection, the IP turns left if the top of the stack is negative, turns right if positive, and keeps moving in its current path if zero.
- The following cases give undefined behavior (or forbidden, depending on implementation):

- - No points or no paths are specified at all.
- - The first point is not on any path.
- - Two points in a program share the same position.
- - A point in a program coincides with an intersection of two paths.
- - Three or more paths intersect at the same position.
- - Two paths are identical.

## Instructions

TBD.

## Syntax

TBD.

## Turing-completeness

Although it is not proven yet, it is believed to be Turing-complete by reduction from Minsky machine given that the language has basic arithmetic (+-*/) instructions (looping and state transition are naturally represented by circles and intersections, respectively).