Unicode operators and precedence?
Ola Fosheim Grøstad
ola.fosheim.grostad at gmail.com
Sun Nov 1 20:15:00 UTC 2020
On Sunday, 1 November 2020 at 19:47:33 UTC, Dominikus Dittes
Scherkl wrote:
>> opUnary!"√"
> This should also be binary (to calculate the n.th root, with n
> an integer >= 2)
> The priority should be rather high.
Thanks, that was an interesting suggestion!
>> opBinary!"·"
> Don't we already have the dot operator (with much too many
> meanings)?
> If you mean some different character, I would recommend to
> refrain from it as it is visual too similar.
It is center-dot, multiplication/inner product: vec1·vec2
On macs you get it with alt+"." I think. IDEs should colour it
differently than the regular "vec1.length" operator, so I think
it will work. But won't know until I try.
>> opBinary!"✕"
>> opBinary!"⊗"
>> opBinary!"⊘"
>> opBinary!"⊙"
> same as *, / ("point" arithmetic)
I wonder if they should be one step higher so that they can be
used for linear algebra? But I am not sure.
It would be nice to do "3*vec1 ✕ 4*vec2" and have it parse as
"(3*vec1) ✕ (4*vec2)"
>> opBinary!"∩"
>> opBinary!"∪"
> same as &, |, ^ ("set" arithmetic - bitwise is only a special
> kind of set)
IIRC D uses the same as C where "&", "|" have higher precedence
than "==" which is not good.
I want to be able to say "A∩B == C" and have it parse as "(A∩B)
== C".
More information about the Digitalmars-d
mailing list