Unicode operators and precedence?

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Sun Nov 1 21:13:07 UTC 2020


On Sunday, 1 November 2020 at 20:52:10 UTC, Dominikus Dittes 
Scherkl wrote:
> I don't understand. if & | ^ had higher prio than == everything 
> would be good.

I meant opposite. In C "&" has higher priority than "==".
https://en.cppreference.com/w/c/language/operator_precedence

I don't want "a&b == c" to parse as "a&(b==c)".

So I want "a∧b == c" to parse as "(a∧b) == c".

I am adding keywords "or", "and" "not" for boolean logic. And 
adding a special quotes «identifier» for creating identifiers. So 
if you in current D have "and(x,y)" then it can be transpiled to 
"«and»(x,y)".

I believe HackerPilot has a scanner-library that can be used for 
automatic code conversion.

> No, they are clearly logic operators and should NOT have set 
> semantics.

Well, it depends on what kind of software one writes. You could 
also view an unsigned int as a vector of bools rather than a set.

> Hmm. Maybe you are right - Xor, Nand and Nor are more useful as 
> additional set operators.

Nand and nor might be nice to have, not sure if people use them 
much, but.

> Ah, i missed one:
> ~  --> ∁ (complement)

I looked at that one, but it is virtually indistinguishable from 
a regular C. I guess it could work if one required it to be used 
like a function:

So allow "∁(MySet)" and disallow "∁MySet" and "MySet∁"




More information about the Digitalmars-d mailing list