Skip to content

Commit e1f8247

Browse files
committed
Add safe show method.
1 parent 81190ed commit e1f8247

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/utils.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,17 @@ for level in [:debug, :info, :warn, :error]
7272
end
7373
end
7474

75+
macro safe_show(exs...)
76+
blk = Expr(:block)
77+
for ex in exs
78+
push!(blk.args,
79+
:(println(Core.stdout, $(sprint(Base.show_unquoted,ex)*" = "),
80+
repr(begin local value = $(esc(ex)) end))))
81+
end
82+
isempty(exs) || push!(blk.args, :value)
83+
return blk
84+
end
85+
7586

7687

7788
## codegen locking

0 commit comments

Comments
 (0)