Skip to content

Instantly share code, notes, and snippets.

@jw3126
Last active October 24, 2017 21:11
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 jw3126/4e0dd861e456536287cd35635f7dd5d5 to your computer and use it in GitHub Desktop.
Save jw3126/4e0dd861e456536287cd35635f7dd5d5 to your computer and use it in GitHub Desktop.
module M
export @esc_none, @esc_all, @esc_args, @esc_args_impl
macro esc_none(x, y)
impl(x,y)
end
macro esc_all(x,y)
esc(impl(x,y))
end
macro esc_args(args...)
impl(esc.(args)...)
end
macro esc_args_impl(args...)
impl_esc(args...)
end
function impl(x,y)
:(foo = $y; $x=foo)
end
function impl_esc(x,y)
:(foo = $(esc(y)); $(esc(x))=foo)
end
end
using M
@show @macroexpand @esc_none x y
@show @macroexpand @esc_all x y
@show @macroexpand @esc_args x y
@show @macroexpand @esc_args_impl x y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment