1
- - Feature Name: macro
1
+ - Feature Name: macro_2_0
2
2
- Start Date: 2016-04-17
3
3
- RFC PR: (leave this empty)
4
4
- Rust Issue: (leave this empty)
@@ -19,10 +19,11 @@ In other RFCs:
19
19
20
20
* Naming and modularisation (#1561 ).
21
21
22
- May be added to this RFC later (or might be separate RFCs) :
22
+ To come in separate RFCs:
23
23
24
24
* more detailed syntax proposal,
25
- * hygiene improvements.
25
+ * hygiene improvements,
26
+ * more ...
26
27
27
28
Note this RFC does not involve procedural macros (aka syntax extensions).
28
29
@@ -50,15 +51,15 @@ fn main() {
50
51
51
52
mod a {
52
53
// Macro privacy (TBA)
53
- pub macro ! foo { ... }
54
+ pub macro foo { ... }
54
55
}
55
56
```
56
57
57
58
``` rust
58
59
// Relative paths (part of hygiene reform, TBA)
59
60
60
61
mod a {
61
- pub macro ! foo { ... bar () ... }
62
+ pub macro foo { ... bar () ... }
62
63
fn bar () { ... }
63
64
}
64
65
@@ -70,7 +71,7 @@ fn main() {
70
71
``` rust
71
72
// Syntax (TBA)
72
73
73
- macro ! foo ($ a : ident ) => {
74
+ macro foo ($ a : ident ) => {
74
75
return $ a + 1 ;
75
76
}
76
77
```
@@ -93,10 +94,10 @@ current hygiene system.
93
94
There will be a new system of macros by example using similar syntax and
94
95
semantics to the current ` macro_rules! ` system.
95
96
96
- A macro by example is declared using the ` macro ` keyword with the ` ! `
97
- operator. For example, where a macro ` foo ` is declared today as `macro_rules!
98
- foo { ... } ` , it will be declared using ` macro! foo { ... }`. I leave the syntax
99
- of the macro body for later specification.
97
+ A macro by example is declared using the ` macro ` keyword. For example, where a
98
+ macro ` foo ` is declared today as ` macro_rules! foo { ... } ` , it will be declared
99
+ using ` macro foo { ... } ` . I leave the syntax of the macro body for later
100
+ specification.
100
101
101
102
102
103
# Drawbacks
@@ -119,23 +120,19 @@ Limit ourselves to backwards compatible changes to `macro_rules!`. I don't think
119
120
this is worthwhile. It's not clear we can make meaningful improvements without
120
121
breaking backwards compatibility.
121
122
123
+ Use ` macro! ` instead of ` macro ` (proposed in an earlier version of this RFC).
124
+
122
125
Don't use a keyword - either make ` macro ` not a keyword or use a different word
123
126
for the macros by example syntax.
124
127
125
- Use ` macro ` instead of ` macro! ` (we might want to use bare ` macro ` for
126
- procedural macros, not clear if the overlap will be a problem).
127
-
128
128
Live with the existing system.
129
129
130
130
131
131
# Unresolved questions
132
132
[ unresolved ] : #unresolved-questions
133
133
134
- What to do with ` macro_rules ` ? We will need to maintain it at least until ` macro! `
134
+ What to do with ` macro_rules ` ? We will need to maintain it at least until ` macro `
135
135
is stable. Hopefully, we can then deprecate it (some time will be required to
136
136
migrate users to the new system). Eventually, I hope we can remove ` macro_rules! ` .
137
137
That will take a long time, and would require a 2.0 version of Rust to strictly
138
138
adhere to our stability guarantees.
139
-
140
- There are many questions still to be answered as this RFC and some sister RFCs
141
- are developed.
0 commit comments