Skip to content
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.

Unicode operator symbols #47

Closed
doug-moen opened this issue Oct 27, 2018 · 4 comments
Closed

Unicode operator symbols #47

doug-moen opened this issue Oct 27, 2018 · 4 comments

Comments

@doug-moen
Copy link
Member

Extend Curv syntax so that a fixed set of Unicode operator symbols is recognized, as a shorter way of writing code that could also be written in ASCII. (Alexandre Garreau proposed the → operator on the Curv mailing list.)

Adding general support for Unicode strings and Unicode identifiers is much harder, and is not part of this feature request.

Here are some ideas:

    90° == 90*deg
    ≤ ≥ ≠
    ¬a == !a
    a·b == dot(a,b)
    a×b == a*b or cross(a,b) -- not sure which is better
    a÷b
    √a  -- what is the precedence of the √ operator?
    a∧b == a&&b
    a∨b == a||b
    x→x+1   ==   x->x+1
    for (i ∈ 1..10)
    π == pi
    τ == tau
    ∞ == inf
    x↑y = x^y
    “foo” == "foo"  -- note, resistant to systems that translate "" to “”
    g∘f == compose[g,f] -- we don't have a compose function yet, it is planned
@TLC123
Copy link
Contributor

TLC123 commented Oct 29, 2018

I like some better than others.

90° == 90*deg Yes agree 
≤ ≥ ≠ Yes agree
¬a == !a No improvement 
a·b == dot(a,b) Mmh slightly unclear 
a×b == a*b or cross(a,b) -- not sure which is better Yes agree a×b 
a÷b Yes but no major improvement
√a  -- what is the precedence of the √ operator? Yes agree 
a∧b == a&&b  Nah not for me 
a∨b == a||b.    Nah not for me 
x→x+1   ==   x->x+1 Yes agree 
for (i ∈ 1..10) Not for me no
π == Pi Yes agree 
τ == tau Yes agree 
∞ == inf Yes agree
x↑y = x^y No less clear 

@bluecube
Copy link

bluecube commented Oct 29, 2018 via email

@doug-moen
Copy link
Member Author

The best reason to implement this feature is to make Curv programs easier to read.

The best reason not to implement this feature is what @bluecube said: it's too hard to type the Unicode characters.

I did some research, and it is not easy to configure all of your computers to have an easy to remember and uniform keyboard interface for typing Unicode technical symbols. Linux systems have a mechanism where you hold down the Compose key, type a 2 character mnemonic, and you get a technical symbol. For example, Compose <= gives ≤. And that's very nice. But you have to configure the Compose key, and you can't type a π this way unless you edit a config file and add a custom key binding. I don't yet know how to configure these same key sequences on a Macintosh. If there was a standard, cross platform solution that was easy to use and covered all of the popular technical symbols, then the Unicode operator feature would be more feasible.

Another alternative for making Curv programs easier to read is to store the program in ASCII on the hard drive, but configure your editor to use typographical tricks to make the on screen presentation more readable. Syntax colouring is one popular trick. Another is to use a programmer's ligature font, so that, for example, <= is presented on screen as ≤.
https://www.hanselman.com/blog/MonospacedProgrammingFontsWithLigatures.aspx

@doug-moen
Copy link
Member Author

Based on @bluecube's comment, I don't think this is a good idea right now, so I'm going to close the issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants