-
-
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
added ⋆ as unary operator #31604
added ⋆ as unary operator #31604
Conversation
as disccussed in [star is not an operator](https://discourse.julialang.org/t/is-not-an-operator/20221/17?u=chakravala)
Can it be a |
@MasonProtter good point, I just committed the change |
For this to work as an infix operator it also needs to be added to a precedence level at the top of the file. |
the |
any update on whether |
So you want the unary operator version of this to be prefix not postfix? Isn't the traditional Kleene star notation postfix? |
This PR seems to be about But the discourse thread was mostly about |
Yes, prefix (not postfix) is used for the Hodge star operation that I implemented in Grassmann.jl julia> using Grassmann
julia> @basis ℝ^3
(⟨+++⟩, v, v₁, v₂, v₃, v₁₂, v₁₃, v₂₃, v₁₂₃)
julia> ⋆(v1), ⋆(v2), ⋆(v3)
(v₂₃, -1v₁₃, v₁₂) @stevengj recommended to use |
@improbable22 is right, julia> ⋆(x,y) = (x+y)/(x - y)
⋆ (generic function with 1 method)
julia> 1 ⋆ 2
-3.0 |
So it should not be added to |
Oh, sorry I misunderstood --- the linked discourse post is about adding \bigstar, so I assumed this was adding that new operator. |
alright, I have reverted the last 2 commits then |
I think both |
are you sure? because this does work for me without it julia> ⋆(x) = x
⋆ (generic function with 1 method)
julia> ⋆8
8
julia> ⋆(x,y) = x+y
⋆ (generic function with 2 methods)
julia> 7⋆8
15 I also get some compile errors when I have Sysimage built. Summary:
Total ─────── 83.465780 seconds
Base: ─────── 27.608859 seconds 33.0781%
Stdlibs: ──── 55.854563 seconds 66.9191%
JULIA usr/lib/julia/sys-o.a
Internal error: encountered unexpected error in runtime:
UndefVarError(var=:li)
rec_backtrace at /home/flow/julia-char/julia/src/stackwalk.c:94
jl_throw at /home/flow/julia-char/julia/src/task.c:210
jl_undefined_var_error at /home/flow/julia-char/julia/src/rtutils.c:130
jl_get_binding_or_error at /home/flow/julia-char/julia/src/module.c:290
_uncompressed_ast at ./reflection.jl:906
typeinf_ext at ./compiler/typeinfer.jl:560
typeinf_ext at ./compiler/typeinfer.jl:599
unknown function (ip: 0x7fc1eb33e417)
jl_apply_generic at /home/flow/julia-char/julia/src/gf.c:2191
jl_apply at /home/flow/julia-char/julia/src/julia.h:1604 [inlined]
jl_type_infer at /home/flow/julia-char/julia/src/gf.c:207
jl_compile_method_internal at /home/flow/julia-char/julia/src/gf.c:1773
jl_apply_generic at /home/flow/julia-char/julia/src/gf.c:2196
jl_apply at /home/flow/julia-char/julia/src/julia.h:1604 [inlined]
jl_finish_task at /home/flow/julia-char/julia/src/task.c:167
jl_threadfun at /home/flow/julia-char/julia/src/partr.c:217
start_thread at /usr/lib/libpthread.so.0 (unknown line)
clone at /usr/lib/libc.so.6 (unknown line)
Generating precompile statements... this error doesn't happen when this PR should be okay as-is right now |
That error is definitely not related to this (fix: #31613). Try |
Alright, here is before julia> [1 ⋆2], [1 ⋆ 2]
([3], [3]) and after julia> [1 ⋆2], [1 ⋆ 2]
([1 2], [3]) you are right, this case needs to be resolved, so I have added it to |
any more comments? is this PR approved? |
any more comments on the star operation? hoping to have this merged for v1.2 |
based on the following Julia pull-requests JuliaLang/julia#24404 JuliaLang/julia#31604
based on the following Julia pull-requests JuliaLang/julia#24404 JuliaLang/julia#31604
as disccussed in star is not an operator