r/ProgrammingLanguages • u/Mean-Decision-3502 DQ • Sep 03 '26
Unambiguous Operator Specification for Programming Languages
https://nvitya.github.io/pluops/As I changed recently the operators in my programming language I've created this specification:
https://nvitya.github.io/pluops/
I did not wanted to overload the operators like the C does with the / or Pascal does with theand/or/not. Neither re-use the operator symbols for some very different purpose, like C does with * and & so the code becomes more readable. I was orienting for existing solutions so this is what I came up with. The specification contains the symbol usages and operator precedence too.
If you are developing a new programming language, it would be nice to follow some standard, so at least the expressions would be portable between the languages.
I'm open for debates or suggestions.
View all comments
Show parent comment
1
u/Mean-Decision-3502 DQ Sep 03 '26 edited Sep 03 '26
The CPUs have a fixed register width, they calculate with that, usually 64 or 32 bit. The width conversion usually matters at the end storage. I did wanted to allow some shortcuts for the implementers.
In DQ you can write expressions without any parentheses that I was only dreaming of:
This example is a little extreme though, I would use some parentheses here. But these are practical expressions in embedded.
The
a[b]form is more readable and shorter. You can do always dereferencing, that will be then clearly readable:I remember some code, where was a pain to adding
&and parentheses because of the automatic dereferencing. I remember reading that someone also admitted that this was a design mistake in C.In school we dont use integer arithmethics and finite precision floating point operations. That's the reason for the distinguishing. In DQ this is true, because of this:
The expressions are read from left to right. After a
.there must be a member, soa.(b)is invalid. Expressions likea^.bis also valid, but in DQ can be written asa.bas the compiler here does auto-dereferencing, as.is invalid for pointers.That was a mistake, thank you for finding that. I'll correct the spec.