This is an automated archive made by the Lemmit Bot.
The original was posted on /r/programminglanguages by /u/aerosayan on 2023-12-14 11:55:51.
Hello, this is somewhat of an open ended question, and I’m not sure how to ask it correctly, but how do you ensure that the rules of your language are correct?
I don’t think there’s a correct answer, other than “try to make it correct”, but since there’s not books on this kind of logical reasoning, I think asking other experienced folks will be educational.
For example,
It’s hard to explain what I mean by “rules” I’m referring to, but here’s an example …
I want to implement refrences/pointers in my language, but since I want to compile down to Fortran, I can’t use pointers, since they cause aliasing, and limit optimization possibilities, specifically in Fortran.
So I just came up with the idea that references/pointers will just be implemented as integer indexes to arrays.
i.e if there’s a large array of cells, we just get the cell at index i, and everywhere the pointer is used, the compiler will substitute it for array_of_cells[i].
This was nice until I realized that I need strict rules for ensuring correctness , like …
- Reference once set, can not be changed within that scope.
- Reference to a local object can not be returned from a function, since the local object will go out of scope and will be deallocated automatically.
- Reference can only be created for objects that are in scope, and unlike C/C++, they can not refer to anywhere random in memory. We need a specific target, and the target can not change.
These are just 3 example rules, but I think I will need hundred more rules like this to ensure proper correctness of the language.
I have to do the work myself, but how do we ensure that we’re not missing something?
Is it just logical reasoning, or is there a framework for inventing/discovering these rules?
I think reading standards of other languages will help, but I don’t have experience in that, because they seem complicated. Although I’m trying to study C and Fortran’s standards because I need them.
Thanks.

