ABCDXYZ

From Esolang
Jump to navigation Jump to search

ABCDXYZ is a reversible object-oriented programming language created by User:ais523 in 2006. It was designed as a language that could be compiled into BackFlip; it is based around the first practical BackFlip storage mechanism to be discovered.

Syntax

An ABCDXYZ program consists of nothing but object definitions. Each object has a value, which can be A, B, C, or D, three methods, called X, Y, and Z, and an event. The only aspect of an object that can be specified by the user is what the event does. Each object is numbered; the numbers must be consecutive nonnegative integers starting at 0, and objects must be defined in numerical order. To define an object, write its number, followed by a colon and whitespace (spaces, tabs, and newlines), and then a list of commands that comprise that object's event. A command consists simply of a method to call (X, Y, or Z) followed by the object's number and whitespace. The only other available command is the output command, consisting of a " character followed by a digit (which prints that digit) or N (which prints a newline). If this command is used, the program cannot be compiled into BackFlip (although it can be compiled into extended BackFlip).

Semantics

At the start of the program, object 0's event fires, and its command list is run. All objects start with value A.

The three predefined methods on each object do the following:

Predefined ABCDXYZ methods
  X Y Z
A Change value to B Change value to B Do nothing
B Change value to C and fire event Change value to C Change value to D
C Change value to D Change value to D and fire event Change value to B
D Change value to A Change value to A Change value to C

The most important rule is that recursion is completely banned: no object may be mentioned if its event is anywhere in the call stack, or undefined behaviour is caused. (For instance, if object 0's event fires object 1's event, which fires object 2's event, object 2's event cannot call any methods of object 1). This implies that object 0 can never be changed at all.

Example

0:
"0 X2 X2 X2 X2 "N

1:
"1 X3 X3 Z3 X3

2:
"2 Y1 Y1 Y1 Y1 

3:
"3

This program produces the following output:

02133

(The output commands at the start of each line are monitoring the flow of the program; the second X in object 0 fires object 2's event, the third Y in object 2 fires object 1's event, and the second and fourth Xs in object 1 fire object 3's event.)

Computational class

ABCDXYZ (without output, which does not affect the computational class) can be compiled into BackFlip, which means that it cannot be of a higher computational class. However, BackFlip's computational class is unknown. The language only has finite data storage and is reversible, implying that it always terminates.

External resources