Come Here

From Esolang
Jump to navigation Jump to search

Come Here is a programming language devised by User:Smjg. Its aim is to do away with the GOTO statement that is considered harmful by many people, but nonetheless is far too common in the world's languages.

To achieve this, the GOTO statement is replaced by COME FROM. Indeed, COME FROM is the only control flow statement in Come Here. Loops and conditionals must be simulated by using COME FROM with a computed argument.

The only data type is the integer. Strings are stored as their little-endian integer representations. There is no defined limit on the size of a Come Here integer. In the official implementation it is unlimited (except by the available memory, of course), but this is not a requirement.

Syntax and statement semantics

Each statement consists of an optional numeric label, a keyword (or in one case, two keywords), followed by one or more juxtaposed arguments. Whitespace is irrelevant.

Statement Description
NOTE one or more tokens Comment
CALL exp var Assigns value exp to variable var.
ASK var Receives a line from stdin and stores it in var.
TELL one or more values Writes the arguments in string form to stdout.
COME FROM exp Transfers control here after the statement labelled exp is executed.

Code example

The following program prints the message "Hello, world!" ten times.

10  CALL 10 count
    COME FROM 10 + SGN count
    TELL "Hello, world!" NEXT
11  CALL count - 1 count

The second line in this code takes the sign of the variable count (0-1, 0 or 1), and therefore comes from the statement labelled 9, 10 or 11 depending on the value of count. It is illegal to COME FROM a non-existent label, hence the dummy label 10. In this instance, count will never be negative; therefore there is no need for a statement to be labelled 9.

Computational class

As long as the implementation places no limit on the size of the integer data type, Come Here is Turing complete since it can simulate a Minsky machine.

Because Come Here has no built-in support for arrays or other data structures, such things must be encoded by using a defined number of integer variables.

External link