ECL
ECL (event control language) by bushbo
Introduction
ECL is a one-dimensional language inspired by Orca, Corewars, and cellular automata. An ECL interpreter operates on a single-dimension memory with a virtual machine executing all instructions in the memory each cycle. Each memory cell can contain a single character, which can be a command (A-Z) or number 0-z (base 36).
ECL embodies the core concepts of live coding as there are no separate edit or compile steps. The system is either in a running or a paused state. The entire state of the machine is stored in memory and is visually available for inspection. Furthermore, there is no hidden internal state or stacks that can grow over time.
Core design goals were to have consistent behavior for operations. Commands are triggered by numbers hitting them (called bang), which happens on the left/top of the command. Optional arguments follow a command. Output from a command always occurs on the right/below after optional arguments. ECL can be visualized as a WxH grid though the operation is on a single-dimension of memory cells. Commands are static in position, however, numbers move to higher addresses at the speed of evaluation.
Numbers
First and foremost, ECL utilizes a base-36 number system:
0-9: numbers as usual a-z: 10-35
Boolean: A zero is considered false, anything else is true.
Operators
General behavior for numbers is that they always move to higher addresses if and only if the address is empty. Example: Here we have a memory space of size N=10 with a single number (1) that evaluated five times. Each line represents the entire memory at a subsequent evaluation.
.1........ ..1....... ...1...... ....1..... .....1....
The memory is wrapped, so this example would infinitely move through memory.
We will introduce our first command, P, which probabilistically passes a number. The probability of passing a number is based on the optional argument. By default, an unspecified value is zero, which drops everything. The value 'z' always passes, whereas others are passed with a probability of arg/z.
With the aforementioned example, adding a P command would halt the number from proceeding.
.1..P..... ..1.P..... ...1P..... ....P..... ....P.....
If we add an argument to P, the probability of a bang proceeding is arg/z. In the following case, the argument is a and thus the probability of the bang proceeding is a/z.
.1..Pa.... ..1.Pa.... ...1Pa.... ....Pa1... ....Pa.1..
What about the transformation of numbers? Let's first look at incrementing numbers (adding one to a value).
.1..I..... ..1.I..... ...1I..... ....I.2... ....I..2..
If an incoming value is z, the output of I overflows to zero.
The space between the command and the resultant number two is an optional argument to the increment command. This particular argument specifies the amount to increment incoming numbers. If we want to increment by three, we just place a three in the argument position.
.1..I3.... ..1.I3.... ...1I3.... ....I34... ....I3.4..
Similarly, we can decrement numbers.
.3..D..... ..3.D..... ...3D..... ....D.2... ....D..2..
Note: Arguments are counted from one, thus ECL is not a zero-based index language.