Created
August 14, 2022 20:49
-
-
Save b-fg/e834a6c7e3cf895edba0fd496d7c4ae2 to your computer and use it in GitHub Desktop.
Julia @out macro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macro out(exs...) | |
blk = Expr(:block) | |
for ex in exs | |
push!(blk.args, :(print($(sprint(Base.show_unquoted, ex) * " = ")))) | |
push!(blk.args, :(show(stdout, "text/plain", begin value=$(esc(ex)) end))) | |
push!(blk.args, :(println())) | |
end | |
isempty(exs) || push!(blk.args, :value) | |
return blk | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Julia macro to output variables using
@show
but in a nicer output format.Usage