Skip to content

Improve documentation of operators#60286

Merged
fingolfin merged 12 commits into
JuliaLang:masterfrom
moble:patch-2
Jan 31, 2026
Merged

Improve documentation of operators#60286
fingolfin merged 12 commits into
JuliaLang:masterfrom
moble:patch-2

Conversation

@moble

@moble moble commented Dec 1, 2025

Copy link
Copy Markdown
Contributor

I've always found the documentation of operators a little disjointed and incomplete; this PR aims to improve the situation.

  • Add missing items to the precedence table
    • Adjoint operator goes after :: and before exponentiation
    • Juxtaposition of numeric literals goes after unary operators and before bitshifts
    • Arrows go between || and ?
    • New footnote explains exceptions to exponentiation precedence
    • New footnote explains non-associativity of comparisons, but notes chaining
  • Add more complete lists of operators
    • Include all operators defined in Base
    • Include operators that are available but not defined in Base, set off by parentheses
  • Operator suffixes
    • Note that new operators can be defined with suffixes
    • Explain what those prefixes are
    • Show an example
  • Provide some links between disjoint pages

@inkydragon inkydragon added the docs This change adds or pertains to documentation label Dec 1, 2025
@moble
moble force-pushed the patch-2 branch 2 times, most recently from b39e988 to d46161e Compare December 1, 2025 16:17
Comment thread doc/src/manual/mathematical-operations.md Outdated
Comment thread doc/src/manual/mathematical-operations.md Outdated
Comment thread doc/src/manual/variables.md Outdated
Comment thread NEWS.md Outdated
Comment thread doc/src/manual/mathematical-operations.md Outdated
@moble
moble force-pushed the patch-2 branch 2 times, most recently from a68df3e to f78985a Compare December 3, 2025 13:52
@moble

moble commented Dec 3, 2025

Copy link
Copy Markdown
Contributor Author

Given that the documentation previously said that a space was required in expressions like the +ᵃx discussed above, I guess we would argue that just parsing it as +ᵃ x is actually a bug, which can be fixed by modifying the parser. As such, I don't want to weaken that language, so I've reverted my change to keep the stronger language.

@moble
moble requested a review from stevengj December 16, 2025 18:58
@Bhupendra-glitch

Copy link
Copy Markdown

hello @moble @stevengj
thanks for working on this — this is a really helpful cleanup of the operator docs.

I’ve been reading through the changes and I’m interested in contributing here as well. In particular, I’d like to help by adding a few concrete examples to clarify operator suffixes and chaining behavior, and double-checking that the precedence/associativity descriptions match actual Julia behavior.

Let me know if you’d prefer examples in a specific section or if there are other gaps you’d like help filling. Happy to open a small follow-up commit if that’s useful.

@moble

moble commented Jan 2, 2026

Copy link
Copy Markdown
Contributor Author

@Bhupendra-glitch Thanks! I'm hoping that this PR could be merged soon, so I think it makes more sense to open that as a separate PR. Feel free to ping me on it!

@stevengj Does this look ready to go to you?

Comment thread doc/src/manual/mathematical-operations.md Outdated
Comment thread doc/src/manual/mathematical-operations.md Outdated
Comment thread doc/src/manual/mathematical-operations.md Outdated

@fingolfin fingolfin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks a nice improvement, thanks a lot!

I've left a bunch of comments. Several are clearly "out of scope" in that they affect text that was there before your PR. These are not meant to block this PR, I just thought you might be able to address them, given that you already familiarized yourself with this. Of course that does not at all mean you have to, or have to do it in this PR.

The one change I care about is explaining the meaning of the parenthesis in the table before the table. Everything else is optional.

Comment thread doc/src/manual/mathematical-operations.md Outdated
Comment thread doc/src/manual/functions.md
Comment thread doc/src/manual/mathematical-operations.md Outdated
Comment thread doc/src/manual/mathematical-operations.md Outdated
Comment thread doc/src/manual/mathematical-operations.md Outdated
Comment thread doc/src/manual/mathematical-operations.md Outdated
Comment thread doc/src/manual/mathematical-operations.md Outdated
Comment thread doc/src/manual/mathematical-operations.md
@moble

moble commented Jan 30, 2026

Copy link
Copy Markdown
Contributor Author

@fingolfin Thanks for your review. You raise good points. I've added a commit that addresses at least some of them, but I still have to go through each of your points to make sure I haven't missed any. I'll respond to them above (though I'm really busy for the rest of the day, so I might not get to everything today).

moble and others added 5 commits January 31, 2026 11:23
- Add adjoint operator to the precedence table at correct precedence
  level between :: and exponentiation
- Explain exceptions to exponentiation precedence
- Include implicit multiplication by juxtaposition of numeric literals in
  precedence table
- Include arrows in precedence table
- Note that comparison operators can be chained with undefined evaluation
  order
- Explain that operators can be used in both infix and functional notation
- Note that new operators can be defined with suffixes, and show an example

@fingolfin fingolfin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@fingolfin
fingolfin merged commit b51d41a into JuliaLang:master Jan 31, 2026
6 of 8 checks passed
fingolfin pushed a commit that referenced this pull request Feb 25, 2026
I've bumped my head against this section of the documentation quite a
number of times (#61055, #60928, #58763), but it looks like I just
missed a pr which massively improved it (#60286). While it caught a
number of things I wanted fixed, there are still some tweaks which
should be added for correctness.

changes:  
 - consolidates duplicated juxtaposition note
 - corrects the straight up wrong ordering of `'` and `::`
 - adds `...` and `,` and `->` and unary `:`
- adds footnotes for a number of exceptions relating to various
operators
   - `.` and `:` must have no spaces
   - `:`, `..`, `'` cannot be dot-distributed
   - `:` parses into groups of three
   - 2-argument `~` is not defined in main
   - `?:` precedence is asymmetric
   - assignment operators get weird with commas

pinging @moble who did the previous pr
mkitti pushed a commit to mkitti/julia that referenced this pull request May 22, 2026
I've bumped my head against this section of the documentation quite a
number of times (JuliaLang#61055, JuliaLang#60928, JuliaLang#58763), but it looks like I just
missed a pr which massively improved it (JuliaLang#60286). While it caught a
number of things I wanted fixed, there are still some tweaks which
should be added for correctness.

changes:  
 - consolidates duplicated juxtaposition note
 - corrects the straight up wrong ordering of `'` and `::`
 - adds `...` and `,` and `->` and unary `:`
- adds footnotes for a number of exceptions relating to various
operators
   - `.` and `:` must have no spaces
   - `:`, `..`, `'` cannot be dot-distributed
   - `:` parses into groups of three
   - 2-argument `~` is not defined in main
   - `?:` precedence is asymmetric
   - assignment operators get weird with commas

pinging @moble who did the previous pr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs This change adds or pertains to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants