Skip to content

Instantly share code, notes, and snippets.

@toivoh
Created August 9, 2012 13:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toivoh/3304162 to your computer and use it in GitHub Desktop.
Save toivoh/3304162 to your computer and use it in GitHub Desktop.
recshow example/test
require("recshow.jl")
type T
x
y
end
type Unshowable; end
show(io::IO, x::Unshowable) = error("Tried to show Unshowable()")
recshowln(x) = (recshow(x); println())
println("Simple and tree structured objects: just as show")
recshowln(1.55)
recshowln(155)
recshowln("abc")
recshowln(T(1,2))
println("\nSelf-referential objects:")
t = T(1,1); t.y = t
recshowln(t)
s = Set(); add(s,s)
recshowln(s)
d = Dict(); d[1]=d
recshowln(d)
println("DAG structured object:")
t1 = T(1,1)
t2 = T(t1,t1)
recshowln(T(t2,t2))
println("Exception during show recording ==> partial printout:")
recshowln(T(t2, Unshowable()))
@toivoh
Copy link
Author

toivoh commented Aug 9, 2012

Output:

Simple and tree structured objects: just as show
1.55
155
"abc"
T(1, 2)

Self-referential objects:
<obj>   = T(1, <obj>)

<obj>   = Set{Any}(<obj>)

<obj>   = {1=><obj>}

DAG structured object:
<obj>   = T(<x1>, <x1>)
<x1>    = T(<x2>, <x2>)
<x2>    = T(1, 1)

Exception during show recording ==> partial printout:
<obj>   = T(T(<x1>, <x1>), #encountered exception!
<x1>    = T(1, 1)
Exception in recshow:
Tried to show Unshowable()
 in recshow at extras/recshow.jl:148
 in recshowln at test.jl:16
 in load at util.jl:230
 in load at util.jl:242
at test.jl:40
 in load at util.jl:253

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment