Dear all,
I am dumbstruck. I just tried the pointless endeavour overriding Base.show
for Int64
. This is what I did (REPL):
julia> import Base.show
julia> Base.show(io::IO, x::Int64) = println("Hello. I am $x")
julia> q = 1
The output is:
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2237 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2419
display_error at ./client.jl:107
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2237 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2419
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1703 [inlined]
jl_f__call_latest at /buildworker/worker/package_linux64/build/src/builtins.c:714
#invokelatest#2 at ./essentials.jl:708 [inlined]
invokelatest at ./essentials.jl:706 [inlined]
_start at ./client.jl:487
jfptr__start_34289.clone_1 at /home/lorenzo/bin/julia-1.6.1/lib/julia/sys.so (unknown line)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2237 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2419
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1703 [inlined]
true_main at /buildworker/worker/package_linux64/build/src/jlapi.c:560
repl_entrypoint at /buildworker/worker/package_linux64/build/src/jlapi.c:702
main at julia (unknown line)
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x4007d8)
repeated thousands of times, during which I am essentially locked out of the terminal.
So the question, of course, is… what gives?
Now I am guessing this is due to the fact that "Hello. I am $x"
calls Base.show
in an infinitely recursive manner. What I don’t understand, however, is the output dump. Is that some sort of stacktrace due to stack smashing? It is worth noting that Julia does something for a while (silently) before dumping that garbage. Also, if that is the case, is that Julia’s normal wy of handling infinite recursion?
Any hints/confirmations would be appreciated! PS. I am using Julia 1.6.1.