Adding Unicode operators to D [use cases]

Don nospam at nospam.com.au
Wed Oct 29 01:33:35 PDT 2008


Andrei Alexandrescu wrote:
> Sergey Gromov wrote:
>> Don wrote:
>>> If you could completely ignore keyboard and display issues, and use any
>>> unicode character as an operator, which ones would you actually use?
>>
>> I'd use dot "⋅" and cross "×" products for 3D, union "∪" and
>> intersection "∩", subset "⊂" and superset "⊃" and their negative forms.
>>  I don't think I'd use anything else.
>>
>> Well, comparisons look better when converted into appropriate unicode.
> 
> In my opinion, a workable feature is this:
> 
> * Functions can be defined with a leading backspace. They will be usable 
> with the infix notation.
> 
> * There is a way of specifying that precedence of a function defined as 
> above is the same as precedence of a built-in operator.

Do we really need to do that? How many Unicode binary operators are there?

This list of symbols which work in web browsers is very short.
http://en.wikipedia.org/wiki/Wikipedia:Mathematical_symbols

The interesting thing about this second list is just how short it is, 
and how many of the items in it are comparison operators.
Any of the unicode comparison operators could be given the same 
precedence as <,> and 'in'.
Cross should be given the same precedence as opMul and opDiv.
That just leaves oplus, otimes, which probably the same precedence as 
plus and mul.

You can do the same thing with this list:
http://en.wikipedia.org/wiki/Unicode_Mathematical_Operators
And you find that the precedence of almost everything is easy to 
determine. Seems like 90% of them are relational operators.

Specifying the precedence of each unicode operator (eg by a lookup 
table) would be adequate for any use case I can imagine, and it wouldn't 
make syntactic analysis any more ambiguous.

> * Functions of which name is the same as an HTML entity name for a 
> symbol can be replaced with the actual symbol.



More information about the Digitalmars-d-announce mailing list