I’m designing and currently rethinking a low-level interpreted programming language with similarities to assembler.
I very soon came across the functions/loops/gotos decision problem and thought that while loops like while and for would be too high-level and unfitting, gotos would be too low level, unmaintainable and generally evil again.
Functions like you know them from most languages that have return values and arguments aren’t fitting in the language’s concept either.
So I tried to figure out something between a function and a goto which is capable of
- Recursion
- Efficient loops
After some thinking I came up with the idea of subroutines:
- They have a beginning and an end like a function
- They have a name but no arguments like a goto
- You can go into one with jump and go out of it again before its end with
return(doesn’t give back any result, only stops the subroutine) - Handled just like normal code -> Global scope like goto
So I wanted to know:
- Is the idea above good? What are the (dis)advantages?
- Would there be a better combination of function and goto or even a completely new idea?
No.
Or at least not until you give a much better explanation of what problems you are trying solve by designing a new language.
No functional abstraction, no recursion, programming only by sharing mutable state. Very weak composition principle. Difficult to use for a human programmer and having no point as a compiler target.
To get somewhere with a project like this, you have to have a goal. If your goal is to learn something, you’re better off studying some great languages and trying to figure what you can steal, what you can combine, or what you can implement. If you have a real problem you’re trying to solve, and it can’t be solved by a standard assembly language, that’s interesting—tell us what it is.
You might try Googling “portable assembly language” and see if you hit anything interesting.