Skip to content
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 \minus equivalent to - operator #26193 #40948

Merged
merged 5 commits into from
May 27, 2021

Conversation

epithet
Copy link
Contributor

@epithet epithet commented May 25, 2021

Add the typographically more correct minus sign (\minus) as an alternative for the traditionally used hyphen-minus - (which is readilly available on all keyboard layouts).

To many, it is aesthetically more pleasing because it has the same width as +. But the main advantage is that it would allow for copy-pasting negative numbers (and to some degree, formulas with subtractions) from correctly typeset PDF/HTML/... documents into Julia code. Actual code snippets can also accidentally be "beautified" by CMS/blog software, word processors, e-mail clients, etc.

Fixes #26193.

@JeffBezanson JeffBezanson added parser Language parsing and surface syntax domain:unicode Related to unicode characters and encodings labels May 26, 2021
@JeffBezanson
Copy link
Sponsor Member

Welcome and great first PR! Seems like a good idea.

@JeffBezanson JeffBezanson added the status:triage This should be discussed on a triage call label May 26, 2021
@JeffBezanson
Copy link
Sponsor Member

This should make it work as an operator, but we also parse - as part of negative numeric literals, so some additional changes are needed to make that work.

@JeffBezanson
Copy link
Sponsor Member

Oh wait I'm wrong, negative literals go through parse-unary so they're already handled. There should be a test for it though.

The remaining case is floating point exponents, e.g. 1.0e-1; we might want to allow the minus there as well.

@JeffBezanson
Copy link
Sponsor Member

−= should maybe also be added.

@epithet epithet marked this pull request as draft May 26, 2021 22:00
@epithet
Copy link
Contributor Author

epithet commented May 26, 2021

@JeffBezanson very good points! I'll see what I can do.

@epithet
Copy link
Contributor Author

epithet commented May 27, 2021

@JeffBezanson

  • have I missed something? (implementation or test coverage)
  • should the documentation mention all these cases?
  • there seem to have been some unrelated hiccups in the CI pipeline, see commit bc48a59

@epithet epithet marked this pull request as ready for review May 27, 2021 10:15
@epithet
Copy link
Contributor Author

epithet commented May 27, 2021

btw: I remembered the existence of rlwrap only halfway through. Could be helpful to mention it here, for example: https://github.com/JuliaLang/julia/blob/bb5b98e72a151c41471d8cc14cacb495d647fb7f/doc/src/devdocs/eval.md#parsingid-dev-parsing
(seemed too insignificant for a separate PR/issue, and not entirely off-topic)

in case "- 42" (unary operator) will get parsed like "-42" (negative literal) in the future
@oscardssmith oscardssmith merged commit 3cdf6a3 into JuliaLang:master May 27, 2021
@oscardssmith oscardssmith removed the status:triage This should be discussed on a triage call label May 27, 2021
@oscardssmith
Copy link
Member

triage approves.

shirodkara pushed a commit to shirodkara/julia that referenced this pull request Jun 9, 2021
johanmon pushed a commit to johanmon/julia that referenced this pull request Jul 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:unicode Related to unicode characters and encodings parser Language parsing and surface syntax
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unicode: Supporting middle dot & real minus
3 participants