Callable
Callable is an esoteric programming language created by User:PythonshellDebugwindow.
Syntax
A Callable program consists of a list of function calls. Function calls take the form F(arguments)
, where F
is the name of the function to be called and arguments
is a comma-separated list of arguments. Valid function names consist entirely of the uppercase letters A-Z, the lowercase letters a-z, and hyphens.
Function arguments can either be function calls or strings. Strings are delimited by double quotes, and can contain any character except for a double quote; there are no escape sequences.
Top-level function calls must be separated by at least a newline, optionally along with other whitespace.
Semantics
All values in Callable are strings. Each function call returns a string.
The execution of a Callable program consists of executing all its top-level functions calls in order.
Attempting to call a nonexistent function causes an error to be raised and the program to be terminated, as does attempting to call a function with an incorrect number of arguments.
List of functions
Unless stated otherwise, each of these functions evaluates all its arguments in the order in which they are passed before performing its function.
Name | Arguments | Description |
---|---|---|
CAT
|
2 | Concatenates its two arguments and returns the result. |
IF-EQ
|
3+ | Evaluates its first two arguments in order. If they are equal, it then evaluates the rest of its arguments in order and returns the result of executing its rightmost argument; otherwise, it returns the empty string. |
IF-NEQ
|
3+ | The same as IF-EQ , except it checks whether its first two arguments are unequal instead of equal.
|
INPUT
|
0 | Reads and returns a line of input. |
PRINT
|
1 | Outputs its argument without a trailing newline, then returns it. |
SEEK
|
2 | If its second argument appears in its first argument starting at some position n and is c characters long, then this function returns a substring of its first argument beginning at position n + c and lasting for c characters (or fewer, if this substring would go out of bounds); otherwise, it returns the empty string. For example, SEEK("HAYSTACK", "AYS") would evaluate to TAC, and SEEK("HAY", "HA") would evaluate to Y.
|
SUBTRACT
|
2 | If its second argument is a prefix of its first, then this function returns its first argument without the prefix; otherwise, it returns its first argument verbatim. |
VAR-GET
|
1 | Returns the value of the variable whose name is equal to its argument. If there is no such variable, the empty string is returned instead. |
VAR-SET
|
2 | Sets the variable whose name is equal to its first argument to its second argument, then returns its second argument. |
WHILE-EQ
|
3+ | Evaluates its first two arguments in order. If they are equal, it then evaluates the rest of its arguments in order. This process is repeated until its first two arguments do not evaluate to the same string, at which point it returns the result of the most recent evaluation of its rightmost argument (if that argument was never evaluated, it instead returns the empty string). |
WHILE-NEQ
|
3+ | The same as WHILE-EQ , except it loops as long as its first two arguments are unequal instead of equal.
|
Examples
Hello, world!
PRINT("Hello, world! ")
Cat
WHILE-EQ( "", "", PRINT(CAT(INPUT(), " ")) )
Truth-machine
VAR-SET("n", INPUT()) WHILE-EQ(VAR-GET("n"), "1", PRINT("1")) PRINT("0")
Computational class
Callable is Turing-complete, as it can implement Bitwise Cyclic Tag. A BCT interpreter written in Callable can be found on GitHub.
External resources
- An interpreter written in Node.js, along with some more examples