-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support many more Unicode infix operators #6929
Conversation
Feels kind of...profligate. You have some duplicates in the operator lists, where we already had some unicode operators. Won't really cause a problem, but untidy. |
|
The n-ary big operators like |
Sure, I can try to remove some of the most similar entries if we don't want to support easily confusable infix operators (although we don't bother to do this for other identifiers like µ and μ), I guess since this is a whitelist it makes more sense to be choosy here. (And yes, there are a few harmless duplications that I was too lazy to remove; I wanted to get a general sense of whether we wanted to do this first.) My feeling is that it is nice to make a rich set of operators available for users to add methods to, even though we won't use most of them in |
Syntax like |
I agree with the overall idea. These characters are definitely infix operators, and the only things you can do with them are disallow them or parse them sensibly. |
I've updated the patch to remove duplicates and near-duplicates (e.g. operators that differ only in size). I also changed the left/right arrows to |
We should also really modify (Not sure what the best way to do that would be, maybe define |
We can add a C API call to fetch the operator table via scm_to_julia. |
Hmm, random Travis error with clang but not gcc. Looks unrelated? |
Yes, unrelated but very troubling :) |
I'm curious @stevengj, how you decided which operators got plus-like precedence versus time-like precedence? Some are obvious – |
@StefanKarpinski, when it wasn't obvious from the shape, I just went with their documented meaning in the Unicode standard: any operator documented as a product, conjunction, intersection, or division of some kind (e.g. ⋋ is left semidirect product) got times precedence, while any operator documented as an addition/subtraction, logical-or, or union of some kind was given plus-like precedence. I used this list of category-Sm code points, which helpfully gives the name of each code point. Operators whose precedence seemed unclear I left out. Did I include any operators whose precedence you found unclear? |
Oh, no – they just weren't all obvious to me, but that seems like a very sane way to do it. |
Note that this basically fixes #552. |
…hould have * precedence despite looking like a union; change NEWS table to only explicitly list operators that are predefined
Another thing that I was thinking of implementing, possibly in a separate PR, is:
Similar to Jeff's remark above, there is no question that e.g. +̂ is an infix operator, so the only things you can do are either to disallow it or to parse it sensibly, and there is no reason that I can see not to parse it sensibly (e.g. the precedence is obvious). Similarly, if we are going to allow This should be pretty easy to implement: you simply strip off any
|
Okay, I was able to put together a sample implementation of the above suggestion for operators+combining characters. It required a few more changes to the parser, though, so I'll leave it for a separate PR when(?) this one is merged. |
I think the "big" N-ary operators should not be infix. |
@JeffBezanson, I thought I got rid of the big N-ary operators; which ones did I miss? |
U+2A00 (⨀), the big circled operators. |
|
Ah, I confused it with U+29BF CIRCLED BULLET. Gotta love unicode... |
Does the |
Yes, that's a very good idea. |
support many more Unicode infix operators
If there is no whitespace between the nearest `\` and the cursor, try to complete a latex symbol or its name *instead* of a Julian name. This allows for interactive discovery of latex names, but whitespace is required for completion of a Julia name. Note that if these completions were instead *appended* to the Julia options, they have to display without the leading \. I found that to be confusing when mixed in with the Julian names. If the word matches a latex name exactly, it replaces it with the symbol. Otherwise, it attempts to complete the latex names. While there are some names that are prefixes to other names, I don't find this to be too jarring. It does effectively "shadow" the longer names, making them harder to discover.
This patch adds support for a much larger number of infix operators, based on my comment in #6582: I went through category Sm manually and pulled out a list of code points that seemed (a) unambiguously infix and (b) had a clear analogy to existing operators so that a reasonable precedence choice could be made.
I don't actually provide definitions for any of the new operators, but now they are available for the user to add methods if she wants to.
It also adds the synonym
∛
forcbrt
, in analogy to√
forsqrt
.cc: @jiahao, @JeffBezanson