# How to print the unprintable? (how to inspect variables where println fails)

**URL:** <https://discourse.julialang.org/t/how-to-print-the-unprintable-how-to-inspect-variables-where-println-fails/118600>\
**Category:** New to Julia\
**Created:** [August 25, 2024, 10:25pm UTC](https://discourse.julialang.org/t/how-to-print-the-unprintable-how-to-inspect-variables-where-println-fails/118600 "2024-08-25T22:25:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![orebas](https://avatars.discourse-cdn.com/v4/letter/o/bbe5ce/32.png) [@orebas](https://discourse.julialang.org/u/orebas)\
**Post date:** [August 25, 2024, 10:25pm UTC](https://discourse.julialang.org/t/how-to-print-the-unprintable-how-to-inspect-variables-where-println-fails/118600/1 "2024-08-25T22:25:08Z")

</div>

I am trying to debug some code which is giving a cryptic error.  
(This is the same MWE from [this question](https://discourse.julialang.org/t/julia-symbolics-error-when-taking-derivative-of-a-quotient/118007). I have made some small changes to the symbolics package, i.e. trying to print out the relevant variables. This is my normal debug procedure, print out some intermediate data and inspect it. )

When I try to print some of the relevant variables, I get an error, which I’ve pasted below. I guess I have a few questions

1. is nameof supposed to be defined for bools? shouldn’t it just be “Bool” or maybe “True” or “False”?
2. Is the point of display() that it’s meant to show nearly anything presentable? It’s worked for me on almost everything else, like matrices, closures, many other things
3. How do I proceed? I’m not sure how to start debugging variables I can’t inspect.

```julia
ERROR: LoadError: MethodError: no method matching nameof(::Bool)
The function `nameof` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  nameof(::Core.IntrinsicFunction)
   @ Base reflection.jl:2273
  nameof(::Num)
   @ Symbolics ~/.julia/dev/Symbolics/src/num.jl:88
  nameof(::Differential)
   @ Symbolics ~/.julia/dev/Symbolics/src/diff.jl:58
  ...

Stacktrace:
  [1] show_call(io::IOContext{Base.TTY}, f::Bool, args::Vector{Any})
    @ SymbolicUtils ~/.julia/packages/SymbolicUtils/iH1dT/src/types.jl:818
  [2] show_term(io::IOContext{Base.TTY}, t::SymbolicUtils.BasicSymbolic{Real})
    @ SymbolicUtils ~/.julia/packages/SymbolicUtils/iH1dT/src/types.jl:863
  [3] show
    @ ~/.julia/packages/SymbolicUtils/iH1dT/src/types.jl:876 [inlined]
  [4] show(io::IOContext{Base.TTY}, ::MIME{Symbol("text/plain")}, x::SymbolicUtils.BasicSymbolic{Real})
    @ Base.Multimedia ./multimedia.jl:47
  [5] (::REPL.var"#68#69"{REPL.REPLDisplay{REPL.LineEditREPL}, MIME{Symbol("text/plain")}, Base.RefValue{Any}})(io::Any)
    @ REPL ~/.julia/juliaup/julia-1.11.0-rc2+0.x64.linux.gnu/share/julia/stdlib/v1.11/REPL/src/REPL.jl:346
  [6] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL ~/.julia/juliaup/julia-1.11.0-rc2+0.x64.linux.gnu/share/julia/stdlib/v1.11/REPL/src/REPL.jl:644
  [7] display(d::REPL.REPLDisplay, mime::MIME{Symbol("text/plain")}, x::Any)
    @ REPL ~/.julia/juliaup/julia-1.11.0-rc2+0.x64.linux.gnu/share/julia/stdlib/v1.11/REPL/src/REPL.jl:332
  [8] display
    @ ~/.julia/juliaup/julia-1.11.0-rc2+0.x64.linux.gnu/share/julia/stdlib/v1.11/REPL/src/REPL.jl:351 [inlined]
  [9] display(x::Any)
    @ Base.Multimedia ./multimedia.jl:340
 [10] expand_derivatives(O::SymbolicUtils.BasicSymbolic{Real}, simplify::Bool; occurrences::Nothing)
    @ Symbolics ~/.julia/dev/Symbolics/src/diff.jl:271
 [11] expand_derivatives(n::Num, simplify::Bool; occurrences::Nothing)
    @ Symbolics ~/.julia/dev/Symbolics/src/diff.jl:323
 [12] expand_derivatives
    @ ~/.julia/dev/Symbolics/src/diff.jl:322 [inlined]
 [13] expand_derivatives(n::Num)
    @ Symbolics ~/.julia/dev/Symbolics/src/diff.jl:322
 [14] main()
    @ Main ~/MWE-test/v2.jl:12
 [15] top-level scope
    @ ~/MWE-test/v2.jl:17
 [16] include(fname::String)
    @ Main ./sysimg.jl:38
 [17] top-level scope
    @ REPL[1]:1
in expression starting at /home/orebas/MWE-test/v2.jl:17

```

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [August 25, 2024, 11:57pm UTC](https://discourse.julialang.org/t/how-to-print-the-unprintable-how-to-inspect-variables-where-println-fails/118600/2 "2024-08-25T23:57:43Z")

</div>

> [@orebas](#):
>
> Is the point of display() that it’s meant to show nearly anything presentable?

`display` ultimately calls `show`, as can be seen from the stacktrace above, so if a package defines a buggy `show` routine (that throws) for a type then it will give an error.

You could call lower-level output routines, like `dump(x)` or `Base.show_default(stdout, x)` (or equivalently `@invoke show(stdout, x::Any)`).

If you have an example of an object where `show` or `display` fails, you should report it as a bug to the package. (In general, you should strive to include minimal reproducible example code in your post so that other people can run it and get the same result.)

---

<div class="post-metadata">

**Author:** ![technocrat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/technocrat/32/220947_2.png) [@technocrat](https://discourse.julialang.org/u/technocrat)\
**Post date:** [August 29, 2024, 6:50am UTC](https://discourse.julialang.org/t/how-to-print-the-unprintable-how-to-inspect-variables-where-println-fails/118600/3 "2024-08-29T06:50:37Z")

</div>

```julia
using About
my_var = π

about(my_var)
Irrational{:π} (<: AbstractIrrational <: Real <: Number <: Any), occupies 0B.
singelton

```
