Skip to content

Instantly share code, notes, and snippets.

Created April 14, 2016 18:11
Show Gist options
  • Save anonymous/27edab73ff29b4861fdc8c186b654b20 to your computer and use it in GitHub Desktop.
Save anonymous/27edab73ff29b4861fdc8c186b654b20 to your computer and use it in GitHub Desktop.
Shared via Rust Playground
#![feature(trace_macros)]
trace_macros!(true);
macro_rules! wrap {
($n:expr) => (wrap!(S($n)))
}
macro_rules! wrap_nocrash {
($($n:tt)*) => (wrap_nocrash!(S($($n)*)))
}
macro_rules! nest2 {
($($n:tt)*) => (id!($($n)*))
}
macro_rules! nest {
($n:expr) => (id_tt!($n))
}
macro_rules! id {
($n:expr) => ($n)
}
macro_rules! id_tt {
($($n:tt)*) => (id!($($n)*))
}
macro_rules! nest3 {
($n:expr) => (nest!(S($n)))
}
fn main() {
//wrap!(0); // Crashes
//wrap2!(0); // Doesn't crash
// nest! { S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(0))))))))))))))))))))))))) }; // Doesn't crash
nest! { S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(0)))))))))))))))))))))))))) };
//nest3! { S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(0))))))))))))))))))))))))) };
//id!{id! { S (S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(0)))))))))))))))))))))))))) ) }};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment