6
6
# Summary
7
7
[ summary ] : #summary
8
8
9
- Macros by example 2.0. A replacement for ` macro_rules! ` . This is mostly a
9
+ Decalrative macros 2.0. A replacement for ` macro_rules! ` . This is mostly a
10
10
placeholder RFC since many of the issues affecting the new macro system are
11
11
(or will be) addressed in other RFCs. This RFC may be expanded at a later date.
12
12
13
13
Currently in this RFC:
14
14
15
- * That we should have a new macro by example system,
16
- * a new keyword for declaring macros.
15
+ * That we should have a new declarative macro system,
16
+ * a new keyword for declaring macros ( ` macro ` ) .
17
17
18
18
In other RFCs:
19
19
@@ -31,14 +31,14 @@ Note this RFC does not involve procedural macros (aka syntax extensions).
31
31
# Motivation
32
32
[ motivation ] : #motivation
33
33
34
- There are several changes to the macro by example system which are desirable but
35
- backwards compatible (See [ RFC 1561] ( https://github.com/rust-lang/rfcs/pull/1561 )
34
+ There are several changes to the declarative macro system which are desirable but
35
+ not backwards compatible (See [ RFC 1561] ( https://github.com/rust-lang/rfcs/pull/1561 )
36
36
for some changes to macro naming and modularisation, I would also like to
37
37
propose improvements to hygiene in macros, and some improved syntax).
38
38
39
39
In order to maintain Rust's backwards compatibility guarantees, we cannot change
40
40
the existing system (` macro_rules! ` ) to accommodate these changes. I therefore
41
- propose a new macro by example system to live alongside ` macro_rules! ` .
41
+ propose a new declarative macro system to live alongside ` macro_rules! ` .
42
42
43
43
Example (possible) improvements:
44
44
@@ -91,14 +91,24 @@ current hygiene system.
91
91
# Detailed design
92
92
[ design ] : #detailed-design
93
93
94
- There will be a new system of macros by example using similar syntax and
94
+ There will be a new system of declarative macros using similar syntax and
95
95
semantics to the current ` macro_rules! ` system.
96
96
97
- A macro by example is declared using the ` macro ` keyword. For example, where a
97
+ A declarative macro is declared using the ` macro ` keyword. For example, where a
98
98
macro ` foo ` is declared today as ` macro_rules! foo { ... } ` , it will be declared
99
99
using ` macro foo { ... } ` . I leave the syntax of the macro body for later
100
100
specification.
101
101
102
+ ## Nomencalture
103
+
104
+ Throughout this RFC, I use 'declarative macro' to refer to a macro declared
105
+ using declarative (and domain specific) syntax (such as the current
106
+ ` macro_rules! ` syntax). The 'declarative macros' name is in opposition to
107
+ 'procedural macros', which are declared as Rust programs. The specific
108
+ declarative syntax using pattern matching and templating is often referred to as
109
+ 'macros by example'.
110
+
111
+ 'Pattern macro' has been suggested as an alterantive for 'declarative macro'.
102
112
103
113
# Drawbacks
104
114
[ drawbacks ] : #drawbacks
@@ -123,7 +133,7 @@ breaking backwards compatibility.
123
133
Use ` macro! ` instead of ` macro ` (proposed in an earlier version of this RFC).
124
134
125
135
Don't use a keyword - either make ` macro ` not a keyword or use a different word
126
- for the macros by example syntax .
136
+ for declarative macros.
127
137
128
138
Live with the existing system.
129
139
0 commit comments