1066
1066 is an esoteric programming language created by User:PythonshellDebugwindow in late 2020.
Syntax and semantics
1066 programs are composed exclusively of CJK characters and newlines.
Function definitions
A 1066 program consists of a series of function definitions, each of which can optionally be followed by a newline (LF or CRLF). Each function definition consists of at least a name and a return value, and can optionally contain parameters, assignments, and output statements.
The simplest possible function definition is of the form 九name丫value乞
. name must be a valid identifier, and value must be a valid value; the former is the name of the function, while the latter is its return value. For example, the following would define a function named 冖
which returns the constant value 0 (乣
):
九冖丫乣乞
Parameters can be indicated by prepending 兄name
one or more times to a function definition. They must come directly before 九
.
Assignments allow values to be bound to names within a function. They come after 丫
but before the function's return value, and take the form name儳value墎
. The assigned value must be a valid value, unless it is the character 卯
, in which case the variable will be set to a bit from the input cache.
Output statements allow bits to be appended to the output cache. They come between a function's assignments and its return value, and are of the form value吇
.
For example, the following line would define a function called 一
which takes a parameter, appends a bit of input to the output cache, and then returns its parameter:
兄二九一丫三儳卯墎三吇二乞
Main function
The main function is named 冖
. It serves as the program's entry point, and cannot take any parameters. Its final return value is used as the program's exit code; 0 means success, while 1 means failure.
Identifiers
Identifiers must consist only of characters in the CJK Unified Ideographs Unicode block which are not used in 1066 commands. Each function, parameter, and variable name must be unique within a program.
Input and output
The input and output caches are stored as big-endian binary UTF-8. For example, the input aβ
would be converted to the 24 bits 01100001 11001110 10110010
.
If a bit is requested from the input cache, it is taken from the front. If the cache is empty, it is first filled with UTF-8 user input.
Whenever the output cache contains a valid UTF-8 character or 32 bits, its contents are output as UTF-8 and then cleared. At the end of the program, if the cache is not empty, it is right-padded with zeros until its length is a multiple of 8 and then output as UTF-8, whether or not it contains valid UTF-8 text.
Values
There are only two values in 1066, namely 0 and 1.
The following commands can be used as values. Unless otherwise stated, each command evaluates its arguments from left to right. All commands have the same precedence and are left-associative.
Command | Effect |
---|---|
x凹y |
Evaluates to y iff x evaluates to 1; otherwise, evaluates to 0 without evaluating y. |
也name |
Calls the function named name and evaluates to its return value. Arguments can be given by prepending 兄value one or more times. The number of arguments given must be equal to the number of parameters of the function to be called; if it is not, then an error is raised before program execution can begin.
|
x习y |
Evaluates x and then y, then evaluates to the logical AND of the two values. |
x乡y |
Evaluates x and then y, then evaluates to the logical OR of the two values. |
x乢 |
Evaluates x, then evaluates to the logical NOT of the result. |
乣 |
Evaluates to 0. |
Additionally, when used as values, variable names evaluate to the value of the associated variable, while other identifiers raise an error before program execution can begin.
Examples
Hello, world!
九冖丫乣吇乣乢吇乣吇乣吇乣乢吇乣吇乣吇乣吇乣吇乣乢吇乣乢吇乣吇乣吇乣乢吇乣吇乣乢吇也矕乡也矕乡也邟乞 九邟丫乣吇乣乢吇乣乢吇乣吇乣乢吇乣乢吇乣乢吇乣乢吇乣吇乣吇乣乢吇乣吇乣乢吇乣乢吇乣吇乣吇乣吇乣吇乣乢吇乣吇乣吇乣吇乣吇乣吇乣吇乣乢吇乣乢吇乣乢吇乣吇乣乢吇乣乢吇乣乢吇乣吇乣乢吇乣乢吇乣吇乣乢吇乣乢吇乣乢吇乣乢吇乣吇乣乢吇乣乢吇乣乢吇乣吇乣吇乣乢吇乣吇也矕乡也人乞 九矕丫乣吇乣乢吇乣乢吇乣吇乣乢吇乣乢吇乣吇乣吇乣乞 九人丫乣吇乣乢吇乣乢吇乣吇乣吇乣乢吇乣吇乣吇乣吇乣吇乣乢吇乣吇乣吇乣吇乣吇乣乢吇乣吇乣吇乣吇乣吇乣乢吇乣吇乣乢吇乣吇乣乞
Cat program
九冖丫一儳卯墎二儳卯墎三儳卯墎四儳卯墎五儳卯墎六儳卯墎七儳卯墎八儳卯墎一吇二吇三吇四吇五吇六吇七吇八吇也冖乞
A more complicated version:
兄人一兄人二兄人三兄人四兄人五兄人六兄人七兄人八九人丫人一吇人二吇人三吇人四吇人五吇人六吇人七吇人八吇也冖乞 九冖丫一儳卯墎二儳卯墎三儳卯墎四儳卯墎五儳卯墎六儳卯墎七儳卯墎八儳卯墎兄一兄二兄三兄四兄五兄六兄七兄八也人乞
Truth-machine
兄邟九矕丫乣吇乣吇乣乢吇乣乢吇乣吇乣吇乣吇邟吇邟凹兄邟也矕乞 九冖丫一儳卯墎二儳卯墎三儳卯墎四儳卯墎五儳卯墎六儳卯墎七儳卯墎八儳卯墎兄八也矕乞
External resources
- An interpreter written in Node.js