Skip to content

Commit

Permalink
Add safe show method.
Browse files Browse the repository at this point in the history
  • Loading branch information
maleadt committed Apr 16, 2024
1 parent 81190ed commit e1f8247
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ for level in [:debug, :info, :warn, :error]
end
end

macro safe_show(exs...)
blk = Expr(:block)
for ex in exs
push!(blk.args,
:(println(Core.stdout, $(sprint(Base.show_unquoted,ex)*" = "),
repr(begin local value = $(esc(ex)) end))))
end
isempty(exs) || push!(blk.args, :value)
return blk
end



## codegen locking
Expand Down

0 comments on commit e1f8247

Please sign in to comment.