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

Addition of Unicode counterparts of some common operators. #41787

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
8 changes: 8 additions & 0 deletions base/exports.jl
Expand Up @@ -166,7 +166,10 @@ export
≠,
!==,
≡,
⩶,
≢,
!⩵,
!⩶,
BenjaminGalliot marked this conversation as resolved.
Show resolved Hide resolved
xor,
⊻,
nand,
Expand All @@ -177,20 +180,25 @@ export
÷,
&,
*,
×,
BenjaminGalliot marked this conversation as resolved.
Show resolved Hide resolved
+,
-,
−,
BenjaminGalliot marked this conversation as resolved.
Show resolved Hide resolved
/,
//,
<,
<:,
<<,
<=,
≤,
⩽,
==,
⩵,
>,
>:,
>=,
≥,
⩾,
>>,
>>>,
\,
Expand Down
26 changes: 20 additions & 6 deletions base/operators.jl
Expand Up @@ -54,6 +54,7 @@ end

"""
==(x, y)
⩵(x, y)

Generic equality operator. Falls back to [`===`](@ref).
Should be implemented for all types with a notion of equality, based on the abstract value
Expand Down Expand Up @@ -84,6 +85,7 @@ If some type defines `==`, [`isequal`](@ref), and [`isless`](@ref) then it shoul
also implement [`<`](@ref) to ensure consistency of comparisons.
"""
==
const ⩵ = ==

"""
isequal(x, y)
Expand Down Expand Up @@ -258,7 +260,7 @@ end

"""
!=(x, y)
≠(x,y)
≠(x, y)

Not-equals comparison operator. Always gives the opposite answer as [`==`](@ref).

Expand All @@ -279,8 +281,9 @@ false
const ≠ = !=

"""
===(x,y) -> Bool
≡(x,y) -> Bool
===(x, y) -> Bool
≡(x, y) -> Bool
stevengj marked this conversation as resolved.
Show resolved Hide resolved
⩶(x, y) -> Bool

Determine whether `x` and `y` are identical, in the sense that no program could distinguish
them. First the types of `x` and `y` are compared. If those are identical, mutable objects
Expand All @@ -304,10 +307,13 @@ true
"""
===
const ≡ = ===
const ⩶ = ===

"""
!==(x, y)
≢(x,y)
!⩵(x, y)
stevengj marked this conversation as resolved.
Show resolved Hide resolved
!⩶(x, y)
≢(x, y)

Always gives the opposite answer as [`===`](@ref).

Expand All @@ -323,6 +329,8 @@ false
```
"""
!==(@nospecialize(x), @nospecialize(y)) = !(x === y)
!⩵(@nospecialize(x), @nospecialize(y)) = !(x === y)
!⩶(@nospecialize(x), @nospecialize(y)) = !(x === y)
const ≢ = !==

"""
Expand Down Expand Up @@ -379,7 +387,8 @@ true

"""
<=(x, y)
≤(x,y)
≤(x, y)
⩽(x, y)

Less-than-or-equals comparison operator. Falls back to `(x < y) | (x == y)`.

Expand All @@ -400,10 +409,12 @@ false
"""
<=(x, y) = (x < y) | (x == y)
const ≤ = <=
const ⩽ = <=

"""
>=(x, y)
≥(x,y)
≥(x y)
⩾(x, y)

Greater-than-or-equals comparison operator. Falls back to `y <= x`.

Expand All @@ -424,6 +435,7 @@ true
"""
>=(x, y) = (y <= x)
const ≥ = >=
const ⩾ = >=

# this definition allows Number types to implement < instead of isless,
# which is more idiomatic:
Expand Down Expand Up @@ -595,6 +607,8 @@ identity(x) = x
(|)(x::Integer) = x
xor(x::Integer) = x

const − = -
BenjaminGalliot marked this conversation as resolved.
Show resolved Hide resolved
const × = *
const ⊻ = xor
const ⊼ = nand
const ⊽ = nor
Expand Down
2 changes: 1 addition & 1 deletion src/julia-parser.scm
Expand Up @@ -15,7 +15,7 @@
(define prec-lazy-and (add-dots '(&&)))
(define prec-comparison
(append! '(in isa)
(add-dots '(> < >= ≥ <= ≤ == === ≡ != ≠ !== ≢ ∈ ∉ ∋ ∌ ⊆ ⊈ ⊂ ⊄ ⊊ ∝ ∊ ∍ ∥ ∦ ∷ ∺ ∻ ∽ ∾ ≁ ≃ ≂ ≄ ≅ ≆ ≇ ≈ ≉ ≊ ≋ ≌ ≍ ≎ ≐ ≑ ≒ ≓ ≖ ≗ ≘ ≙ ≚ ≛ ≜ ≝ ≞ ≟ ≣ ≦ ≧ ≨ ≩ ≪ ≫ ≬ ≭ ≮ ≯ ≰ ≱ ≲ ≳ ≴ ≵ ≶ ≷ ≸ ≹ ≺ ≻ ≼ ≽ ≾ ≿ ⊀ ⊁ ⊃ ⊅ ⊇ ⊉ ⊋ ⊏ ⊐ ⊑ ⊒ ⊜ ⊩ ⊬ ⊮ ⊰ ⊱ ⊲ ⊳ ⊴ ⊵ ⊶ ⊷ ⋍ ⋐ ⋑ ⋕ ⋖ ⋗ ⋘ ⋙ ⋚ ⋛ ⋜ ⋝ ⋞ ⋟ ⋠ ⋡ ⋢ ⋣ ⋤ ⋥ ⋦ ⋧ ⋨ ⋩ ⋪ ⋫ ⋬ ⋭ ⋲ ⋳ ⋴ ⋵ ⋶ ⋷ ⋸ ⋹ ⋺ ⋻ ⋼ ⋽ ⋾ ⋿ ⟈ ⟉ ⟒ ⦷ ⧀ ⧁ ⧡ ⧣ ⧤ ⧥ ⩦ ⩧ ⩪ ⩫ ⩬ ⩭ ⩮ ⩯ ⩰ ⩱ ⩲ ⩳ ⩵ ⩶ ⩷ ⩸ ⩹ ⩺ ⩻ ⩼ ⩽ ⩾ ⩿ ⪀ ⪁ ⪂ ⪃ ⪄ ⪅ ⪆ ⪇ ⪈ ⪉ ⪊ ⪋ ⪌ ⪍ ⪎ ⪏ ⪐ ⪑ ⪒ ⪓ ⪔ ⪕ ⪖ ⪗ ⪘ ⪙ ⪚ ⪛ ⪜ ⪝ ⪞ ⪟ ⪠ ⪡ ⪢ ⪣ ⪤ ⪥ ⪦ ⪧ ⪨ ⪩ ⪪ ⪫ ⪬ ⪭ ⪮ ⪯ ⪰ ⪱ ⪲ ⪳ ⪴ ⪵ ⪶ ⪷ ⪸ ⪹ ⪺ ⪻ ⪼ ⪽ ⪾ ⪿ ⫀ ⫁ ⫂ ⫃ ⫄ ⫅ ⫆ ⫇ ⫈ ⫉ ⫊ ⫋ ⫌ ⫍ ⫎ ⫏ ⫐ ⫑ ⫒ ⫓ ⫔ ⫕ ⫖ ⫗ ⫘ ⫙ ⫷ ⫸ ⫹ ⫺ ⊢ ⊣ ⟂ ⫪ ⫫ <: >:))))
(add-dots '(> < >= ≥ <= ≤ == === ≡ != ≠ !== !⩵ !⩶ ≢ ∈ ∉ ∋ ∌ ⊆ ⊈ ⊂ ⊄ ⊊ ∝ ∊ ∍ ∥ ∦ ∷ ∺ ∻ ∽ ∾ ≁ ≃ ≂ ≄ ≅ ≆ ≇ ≈ ≉ ≊ ≋ ≌ ≍ ≎ ≐ ≑ ≒ ≓ ≖ ≗ ≘ ≙ ≚ ≛ ≜ ≝ ≞ ≟ ≣ ≦ ≧ ≨ ≩ ≪ ≫ ≬ ≭ ≮ ≯ ≰ ≱ ≲ ≳ ≴ ≵ ≶ ≷ ≸ ≹ ≺ ≻ ≼ ≽ ≾ ≿ ⊀ ⊁ ⊃ ⊅ ⊇ ⊉ ⊋ ⊏ ⊐ ⊑ ⊒ ⊜ ⊩ ⊬ ⊮ ⊰ ⊱ ⊲ ⊳ ⊴ ⊵ ⊶ ⊷ ⋍ ⋐ ⋑ ⋕ ⋖ ⋗ ⋘ ⋙ ⋚ ⋛ ⋜ ⋝ ⋞ ⋟ ⋠ ⋡ ⋢ ⋣ ⋤ ⋥ ⋦ ⋧ ⋨ ⋩ ⋪ ⋫ ⋬ ⋭ ⋲ ⋳ ⋴ ⋵ ⋶ ⋷ ⋸ ⋹ ⋺ ⋻ ⋼ ⋽ ⋾ ⋿ ⟈ ⟉ ⟒ ⦷ ⧀ ⧁ ⧡ ⧣ ⧤ ⧥ ⩦ ⩧ ⩪ ⩫ ⩬ ⩭ ⩮ ⩯ ⩰ ⩱ ⩲ ⩳ ⩵ ⩶ ⩷ ⩸ ⩹ ⩺ ⩻ ⩼ ⩽ ⩾ ⩿ ⪀ ⪁ ⪂ ⪃ ⪄ ⪅ ⪆ ⪇ ⪈ ⪉ ⪊ ⪋ ⪌ ⪍ ⪎ ⪏ ⪐ ⪑ ⪒ ⪓ ⪔ ⪕ ⪖ ⪗ ⪘ ⪙ ⪚ ⪛ ⪜ ⪝ ⪞ ⪟ ⪠ ⪡ ⪢ ⪣ ⪤ ⪥ ⪦ ⪧ ⪨ ⪩ ⪪ ⪫ ⪬ ⪭ ⪮ ⪯ ⪰ ⪱ ⪲ ⪳ ⪴ ⪵ ⪶ ⪷ ⪸ ⪹ ⪺ ⪻ ⪼ ⪽ ⪾ ⪿ ⫀ ⫁ ⫂ ⫃ ⫄ ⫅ ⫆ ⫇ ⫈ ⫉ ⫊ ⫋ ⫌ ⫍ ⫎ ⫏ ⫐ ⫑ ⫒ ⫓ ⫔ ⫕ ⫖ ⫗ ⫘ ⫙ ⫷ ⫸ ⫹ ⫺ ⊢ ⊣ ⟂ ⫪ ⫫ <: >:))))
(define prec-pipe< '(|.<\|| |<\||))
(define prec-pipe> '(|.\|>| |\|>|))
(define prec-colon (append! '(: |..|) (add-dots '(… ⁝ ⋮ ⋱ ⋰ ⋯))))
Expand Down