-
-
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
Make \cdot and \cdotp operators equivalent #25157
Conversation
Shouldn't this be done as in #19464? |
Probably. I'm not an expert on how to do this. I'll follow this thread and I'll study the PR #19464 in order to figure out how it can be done. Thanks |
Yes, the right way to do this is to just add a line to https://github.com/JuliaLang/julia/blob/master/src/flisp/julia_charmap.h to make this substitution. Also add a note to NEWS, documentation at the end of https://github.com/JuliaLang/julia/blob/master/doc/src/manual/variables.md#allowed-variable-names (along with the note about ε), and add a test. |
(Note also that you shouldn't open a new PR. Just revert the commit in this branch and push new commits to fix it the right way. It will all get squashed into a single commit when it is merged. That way all of the discussion will go together.) |
Yes. I'll do that :-) Thanks @stevengj |
doc/src/manual/variables.md
Outdated
@@ -122,7 +122,8 @@ Different ways of entering Unicode combining characters (e.g., accents) | |||
are treated as equivalent (specifically, Julia identifiers are NFC-normalized). | |||
The Unicode characters `ɛ` (U+025B: Latin small letter open e) | |||
and `µ` (U+00B5: micro sign) are treated as equivalent to the corresponding | |||
Greek letters, because the former are easily accessible via some input methods. | |||
Greek letters, and '·' (U+00B7: Middle dot) is treated as the mathematical |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe link https://en.wikipedia.org/wiki/Interpunct
Needs a NEWS item, then should be good to go. |
Not yet, I think. I don't know if I'm missing something but Julia still complains about julia> ·
ERROR: syntax: invalid character "·" I'm pretty sure that this should be fixed in Summary: I checked a random equivalence and it works julia> €
+ (generic function with 177 methods) Could I suggest @JeffBezanson to review this? |
Oh, I know the problem. The issue is that normalization of symbols only happens after they are parsed in the file, and since The fix, at first glance, should be to add |
I checked this and it does not work. Now it is a valid identifier but it seems that the mapping arrives before since julia> ·
ERROR: UndefVarError: · not defined Maybe this is necessary, but still does not fix it. The character inserted and the displayed in the error are U+00b7. |
It could be that the normalization is not done to operators (as opposed to ordinary variable names), let me check. |
Yup, the normalization is only done to variable names, not to operators. There would need to be a call to a normalization routine at the end of |
Nice! With that I think I'm able to finish this. Thanks a lot! |
src/julia-parser.scm
Outdated
@@ -549,7 +549,9 @@ | |||
op)) | |||
(else '|.|))))) | |||
|
|||
((opchar? c) (read-operator port (read-char port))) | |||
((if (opchar? c) | |||
(accum-julia-symbol c port) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this is wrong; accum-julia-symbol
reads an identifier (not an operator) from the input stream, leaving nothing else for read-operator
to read.
I think you will need to export a new flisp function to normalize a symbol
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a new commit. It works now after make cleanall
and make
It works now for me after julia> ⋅ # \cdotp[TAB] or U+00b7
dot (generic function with 9 methods)
julia> · # \cdot[TAB] or U+22c5
dot (generic function with 9 methods)
julia> dot
dot (generic function with 9 methods) Should I do it in another way? I'm not able to find an alternative. |
Ping, what this the status here? |
I'm not able to write anything that really works. I think we should work on the parser, which is written in SCM/C++. At the moment I have no time to learn all this. It seems that there is a function in the parser that only works to make equivalent the identifiers, but not the operators. Help is needed, or a new PR should be opened to solve the issue. |
I can help with this at some point, but it's not urgent since it's a non-breaking change. |
Some relevant discussion on Discourse. |
A summary of the Discourse discussion based on my understanding:
|
PR #28167 removes U+0387 from the list of valid identifiers. If this PR is revived at some point, we will want to normalize both U+0387 and U+00b7 to U+22c5 ( |
1f54c9c
to
bea33a1
Compare
I rebased this on |
4f743d8
to
796f62f
Compare
Thanks! This will help a lot of people using a spanish keyboard layout, since U+00B7 is just typed by pressing SHIFT+3. Thanks again |
Could this make its way to 1.6? |
Too late for 1.6, I think. |
ddfba23
to
d2e6c1e
Compare
Co-authored-by: Steven G. Johnson <stevenj@alum.mit.edu>
d2e6c1e
to
e1c803a
Compare
Triage didn't seem to see why this was put on the list. It seemed like nobody had objected to merging? |
Co-authored-by: Steven G. Johnson <stevenj@alum.mit.edu> Co-authored-by: Steven G. Johnson <stevenj@alum.mit.edu>
Co-authored-by: Steven G. Johnson <stevenj@alum.mit.edu> Co-authored-by: Steven G. Johnson <stevenj@alum.mit.edu>
Co-authored-by: Steven G. Johnson <stevenj@alum.mit.edu> Co-authored-by: Steven G. Johnson <stevenj@alum.mit.edu>
It includes an enhancement discussed in #25098
(See also https://discourse.julialang.org/t/inconsistencies-in-some-methods-and-more/7788)