Last active
October 24, 2017 21:11
-
-
Save jw3126/4e0dd861e456536287cd35635f7dd5d5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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