The 2Iota Programming Language

Language version 1.0, revision 2010.0428.
©2004-2010 Cat's Eye Technologies.

Overview

2Iota is the successor language to the beta-Juliet and Portia languages. It is extremely similar — nearly identical — in syntax and semantics to these languages, with the following exceptions:

  • 2Iota is a single language rather than a pair of mutual languages;
  • 2Iota is Turing-Complete (or at least, closer to TC than beta-Juliet plus Portia);
  • 2Iota does not (yet) implement caused after|before|by clauses;
  • 2Iota explicitly reserves syntax for implementation-specific pragmas and system events;
  • 2Iota's reference implementation is written in C rather than Perl;
  • 2Iota's reference implementation actually implements delays. (Compiled as C99 with POSIX, delays have millisecond granularity; compiled as ANSI C they have second granularity.)

Events

2Iota is a fairly "pure" event-oriented language. In 2Iota, the world is modelled as a set of events which have no inherent organization or ordering. One such set might be Domino Falls, Cat Meows, Sun Sets, Address Line Six Goes High and Greengrocer Falls Asleep on Subway.

The occurance of each event may cause any number of other events to happen — these are termed consequences of the event. These consequences may be conditional. However, the only condition available for checking is: given two events, which one happened more recently?

Patterns

The names of events in 2Iota may be literal strings of symbols, exemplified above, or they may be patterns. Patterns contain parameters and act something like regular expressions. Each parameter ranges over a specified alphabet. When an event occurs which matches the name of an event, the parameters in that name are bound to the literal symbols in the occurring event. These bound parameters may then be used in substitutions in the consequences.

For example, if we have an alphabet called Animal that consists of the symbols Dog Cat Ferret, we can have an event (X=Animal) Licks Itself which has, as a consequence, (X) Becomes Clean. Here X is a parameter. This event will happen should some other event cause Cat Licks Itself; X will be bound to Cat, and this event will thus subsequently cause the event Cat Becomes Clean.

Modifiers

Unlike events, alphabets are ordered. Each symbol (except the first) in an alphabet has one and only one predecessor, and each symbol (except the last) has one and only one successor.

So the range of symbols in an alphabet is bounded. However, when considering a string of symbols (or a symbol-string), such as the name of an event, we can use something resembling Peano arithmetic to generate an unbounded sequence of symbol-strings, so long as each symbol in a string is in the same alphabet.

Thus, for some alphabet, every symbol-string has one and only one successor. Again, though, there is one symbol-string which has no predecessor — the symbol-string which is one symbol long, where that symbol is the first symbol of the alphabet.

These concepts are implemented in 2Iota with modifiers. When a parameter is named in a consequence, it is replaced by the value it is bound to, and this can be altered by one of the following modifiers:

  • next — assuming the value is a single symbol, use the next symbol in its alphabet instead;
  • prev — assuming the value is a single symbol, use the previous symbol in its alphabet instead;
  • succ — assuming the value is a symbol-string, use the successor symbol-string over its alphabet;
  • pred — assuming the value is a symbol-string, use the predecessor symbol-string over its alphabet instead.

Note that all of these modifiers (except succ) can fail. In this case, an alternate or failure-mode modifier or symbol can be given, and this will be used instead.