Skip to content

Commit

Permalink
make \minus equivalent to - operator #26193
Browse files Browse the repository at this point in the history
  • Loading branch information
epithet committed May 25, 2021
1 parent 829d7e0 commit c413a19
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Language changes

* `macroexpand`, `@macroexpand`, and `@macroexpand1` no longer wrap errors in a `LoadError`. To reduce breakage, `@test_throws` has been modified so that many affected tests will still pass ([#38379]].
* The middle dot `·` (`\cdotp` U+00b7) and the Greek interpunct `·` (U+0387) are now treated as equivalent to the dot operator `` (`\cdot` U+22c5) (#25157).
* The minus sign `` (`\minus` U+2212) is now treated as equivalent to the hyphen-minus sign `-` (U+002d).

Compiler/Runtime improvements
-----------------------------
Expand Down
1 change: 1 addition & 0 deletions doc/src/manual/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ are treated as equivalent to the corresponding Greek letters. The middle dot
`·` (U+00B7) and the Greek
[interpunct](https://en.wikipedia.org/wiki/Interpunct) `·` (U+0387) are both
treated as the mathematical dot operator `` (U+22C5).
The minus sign `` (U+2212) is treated as equivalent to the hyphen-minus sign `-` (U+002D).

## Stylistic Conventions

Expand Down
1 change: 1 addition & 0 deletions src/flisp/julia_charmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ static const uint32_t charmap[][2] = {
{ 0x00B5, 0x03BC }, // micro sign -> greek small letter mu
{ 0x00B7, 0x22C5 }, // middot char -> dot operator (#25098)
{ 0x0387, 0x22C5 }, // Greek interpunct -> dot operator (#25098)
{ 0x2212, 0x002D }, // minus -> hyphen-minus (#26193)
};
2 changes: 1 addition & 1 deletion src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
(define prec-pipe> '(|.\|>| |\|>|))
(define prec-colon (append! '(: |..|) (add-dots '(… ⁝ ⋮ ⋱ ⋰ ⋯))))
(define prec-plus (append! '($)
(add-dots '(+ - ¦ |\|| ⊕ ⊖ ⊞ ⊟ |++| ∪ ∨ ⊔ ± ∓ ∔ ∸ ≏ ⊎ ⊻ ⊽ ⋎ ⋓ ⧺ ⧻ ⨈ ⨢ ⨣ ⨤ ⨥ ⨦ ⨧ ⨨ ⨩ ⨪ ⨫ ⨬ ⨭ ⨮ ⨹ ⨺ ⩁ ⩂ ⩅ ⩊ ⩌ ⩏ ⩐ ⩒ ⩔ ⩖ ⩗ ⩛ ⩝ ⩡ ⩢ ⩣))))
(add-dots '(+ - ¦ |\|| ⊕ ⊖ ⊞ ⊟ |++| ∪ ∨ ⊔ ± ∓ ∔ ∸ ≏ ⊎ ⊻ ⊽ ⋎ ⋓ ⧺ ⧻ ⨈ ⨢ ⨣ ⨤ ⨥ ⨦ ⨧ ⨨ ⨩ ⨪ ⨫ ⨬ ⨭ ⨮ ⨹ ⨺ ⩁ ⩂ ⩅ ⩊ ⩌ ⩏ ⩐ ⩒ ⩔ ⩖ ⩗ ⩛ ⩝ ⩡ ⩢ ⩣))))
(define prec-times (add-dots '(* / ⌿ ÷ % & · · ⋅ ∘ × |\\| ∩ ∧ ⊗ ⊘ ⊙ ⊚ ⊛ ⊠ ⊡ ⊓ ∗ ∙ ∤ ⅋ ≀ ⊼ ⋄ ⋆ ⋇ ⋉ ⋊ ⋋ ⋌ ⋏ ⋒ ⟑ ⦸ ⦼ ⦾ ⦿ ⧶ ⧷ ⨇ ⨰ ⨱ ⨲ ⨳ ⨴ ⨵ ⨶ ⨷ ⨸ ⨻ ⨼ ⨽ ⩀ ⩃ ⩄ ⩋ ⩍ ⩎ ⩑ ⩓ ⩕ ⩘ ⩚ ⩜ ⩞ ⩟ ⩠ ⫛ ⊍ ▷ ⨝ ⟕ ⟖ ⟗ ⨟)))
(define prec-rational (add-dots '(//)))
(define prec-bitshift (add-dots '(<< >> >>>)))
Expand Down
5 changes: 4 additions & 1 deletion test/syntax.jl
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ let f = function (x; kw...)
end

# normalization of Unicode symbols (#19464)
let ε=1, μ=2, x=3, î=4, =5
let ε=1, μ=2, x=3, î=4, =5, (-)=6
# issue #5434 (mu vs micro):
@test Meta.parse("\u00b5") === Meta.parse("\u03bc")
@test µ == μ == 2
Expand All @@ -832,6 +832,9 @@ let ε=1, μ=2, x=3, î=4, ⋅=5
# middot char · or · vs math dot operator ⋅ (#25098)
@test Meta.parse("\u00b7") === Meta.parse("\u0387") === Meta.parse("\u22c5")
@test (·) == (·) == () == 5
# minus − vs hyphen-minus - (#26193)
@test Meta.parse("\u2212") === Meta.parse("\u002d")
@test () == (-) == 6
end

# issue #8925
Expand Down

0 comments on commit c413a19

Please sign in to comment.