You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Recursive macros are macros that call themselves (perhaps with different arguments)
141
+
142
+
```rust
143
+
#[macro_use]
144
+
modm {
145
+
macro_rules!print_expr {
146
+
($e:expr) => {{
147
+
println!("Going to do {}", stringify!($e));
148
+
print_expr!(no_print=>$e)
149
+
}};
150
+
(no_print=>$e:expr) => {{
151
+
$e
152
+
}};
153
+
}
154
+
}
155
+
156
+
fnmain() {
157
+
print_expr!(1+1)
158
+
}
159
+
```
160
+
161
+
Naively changing this to path based scope would not work as it is not guaranteed that the unqualified `print_expr` name is in scope. In the example above, `print_expr!` is used recursively inside the macro, but in a path scoped system the recursive call would not be in scope if the macro was called with a qualified path (e.g., user calls `m::print_expr!` which references unqualified `print_expr!` which is not in scope).
162
+
163
+
TODO: Describe how we'll handle this
164
+
165
+
### "Private" macros
166
+
167
+
Macros can use "private" macros (i.e., macros defined inside of other macros).
0 commit comments