Hi, I'm making a programming language (untitled so far). I already have the basic idea of what the syntax will be like (at least for the code segment). Here's an example line of code (Fahrenheit to Celsius formula):
F 32 SUB 5 9 DIV MUL
Here's how it works:
The code segment of the language is just values (variables, constants, integers, etc.) and functions (or operands depending on how you look at it) separated by whitespace (could be one space, twenty tabs, a thousand line breaks, etc.)
The first function is found, and ran. A function has access to all preceding values. After the function has run, the values used by the function and the function call are replaced by the function's output values (yes, can be more than one). The next function is found, and ran. The next function is found, and ran...
This is repeated until there are no more functions. For example, back to the Fahrenheit to Celsius formula:
F 32 SUB 5 9 DIV MUL
Here's how this code would run:
212 32 SUB 5 9 DIV MUL (the actual code)
180 5 9 DIV MUL (212 - 32 = 180)
180 0.55555555 MUL (5 / 9 = 0.55555555...)
100 (return)
Another example:
1 2 3 4 5 ADD ADD ADD ADD (the actual code)
1 2 3 9 ADD ADD ADD
1 2 12 ADD ADD
1 14 ADD
15 (return)
So do you think that I'm on to something here? I kind of consider this reinventing the programming language (Actually I believe that there was a similar language).
I'm going to build a small program that inputs from the user a code segment with the five basic math operators (don't forget mod) and then outputs the leftover values.