You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.10.5 (2024-08-27)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia> using SIMD
julia> println(repr(Vec(1.0, 2.0, 3.0, 4.0)))
<4 x Float64>[1.0, 2.0, 3.0, 4.0]
julia> <4 x Float64>[1.0, 2.0, 3.0, 4.0]
ERROR: ParseError:
# Error @ REPL[3]:1:1
<4 x Float64>[1.0, 2.0, 3.0, 4.0]
╙ ── not a unary operator
Stacktrace:
[1] top-level scope
@ none:1
In general, the output of repr(x) is supposed to be an executable Julia expression that evaluates to x. I just fixed the same issue in MultiFloats.jl and realized it also exists upstream in SIMD.jl.
You can see the approach I took to fix this problem in commit c996294. Basically, instead of overloading Base.show(::IO, ::MultiFloat) directly, I separately overload Base.show(::IO, ::MIME"text/plain", ::MultiFloat) and Base.print(::IO, ::MultiFloat) to print the pretty representation of a MultiFloat, which lets the default Base.show implementation print the ugly-but-executable representation. This still prints the pretty representation in functions like string and println and the Julia/IJulia REPL.
In general, the output of
repr(x)
is supposed to be an executable Julia expression that evaluates tox
. I just fixed the same issue in MultiFloats.jl and realized it also exists upstream in SIMD.jl.You can see the approach I took to fix this problem in commit
c996294
. Basically, instead of overloadingBase.show(::IO, ::MultiFloat)
directly, I separately overloadBase.show(::IO, ::MIME"text/plain", ::MultiFloat)
andBase.print(::IO, ::MultiFloat)
to print the pretty representation of aMultiFloat
, which lets the defaultBase.show
implementation print the ugly-but-executable representation. This still prints the pretty representation in functions likestring
andprintln
and the Julia/IJulia REPL.In fact, feel free to use my code for
show
ing aVec
:The text was updated successfully, but these errors were encountered: