++C
++C (alternatively called PostC) is a C++ based esoteric programming language created by User:Yee haw in 2022. The premise of ++C is using postfix notation with the traditional C++ syntax.
Syntax
In ++C, all C++ identifiers are classified as either operators or operands. As such, all C++ programs can be restructured to be valid ++C programs. Here is an example of a simple Hello World program:
"Hello World!" cout <<;
In this case, the stream insertion operator takes it's lvalue, a string literal, and hands it to the C++ output stream. The order of an operator's operands does matter in ++C.
Operators can be either unary or binary. Unary operators take a single operand off of the stack and push a single value back onto the stack.
Just like in mathematical postfix notation, each operator returns a certain value. For some binary operators, it's uncertain whether the lvalue or rvalue should be returned, such as in the case of the stream insertion operator. In those cases, the lvalue will be ignored and the rvalue will always be returned.
In most other cases, such as in the case of the addition operator, the order of the operands doesn't matter and there's only one valid return value.
++C is a stack-based language, meaning that all operands are held on a large stack and are sequentially pushed on and popped off. The semicolon at the end of each line resets this stack, so that each line has a clean stack to use.
Notable Differences From C++
Many expressions that would usually be invalid in C++ are valid in ++C. For instance, the following code is illegal in C++:
cout << string a = "Hi" << endl;
But in ++C, the same line can be written legally as follows:
endl a string "Hi" = cout << <<;
This is thanks to the extra control ++C gives the user in terms of control over operator precedence. In ++C, no such thing as operator precedence exists; lines are just executed from left to right.
Unlike C++, ++C requires spaces between operands, as there are no operators to separate them. In C++, the following line does not require any spaces:
cout<<"hi"<<endl;
The same line written in ++C would require a space between the endl, cout, and "hi".
Examples
Hello World:
"Hello World" cout <<;
A simple calculator program:
{ "Enter two integers: " cout <<; x int y int cin >> >>; "What operation would you like to perform? (+, -, +, /) " cout <<; operator string cin >>; { sum int x y + =; endl sum "\nTheir sum is " cout << << <<; } (operator "+" ==) if; { difference int x y - =; endl difference "\nTheir difference is " cout << << <<; } (operator "-" ==) if; { product int x y * =; endl product "\nTheir product is " cout << << <<; } (operator "*" ==) if; { quotient double x y / =; endl quotient "\nTheir quotient is " cout << << <<; } (operator "/" ==) if; "Would you like to run the program again? (y/n) " cout <<; input string; break (input "N" == input "n" == ||) if; } true while;