Skip to content

Commit 85e4ec0

Browse files
authored
clarify a bit around macro arguments (#2018)
1 parent a395bf2 commit 85e4ec0

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

working/macros/feature-specification.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,14 @@ Here, if `myCoolMacro` resolves to an instance of a class implementing one or
8383
more of the macro interfaces, then the annotation is treated as an application
8484
of the `myCoolMacro` macro to the class MyClass.
8585

86-
### Arguments
86+
Macro applications can also be passed arguments, either in the form of
87+
[Code][] expressions or certain types of literal values. See
88+
[Macro Arguments](#Macro-arguments) for more information on how these arguments
89+
are handled when executing macros.
8790

88-
Macro applications can also be passed arguments. For example:
91+
### Code Arguments
92+
93+
Consider this example macro application:
8994

9095
```dart
9196
int get a => 1;
@@ -97,11 +102,11 @@ class SomeClass {
97102
}
98103
```
99104

100-
Here, `Add` is a macro that takes its arguments and produces a function body
101-
that adds them using `+` and returns the result.
105+
Here, `Add` is a macro that takes its arguments as expressions and produces a
106+
function body that adds them using `+` and returns the result.
102107

103108
Because macros are applied at compile time, the arguments are passed to the
104-
macro as objects representing unevaluated pieces of code. Here, the `Add` macro
109+
macro as objects representing unevaluated expressions. Here, the `Add` macro
105110
receives objects that represent the *literal* `1` and *the expression* `a + b`.
106111
It takes those and composes them into a function body like:
107112

0 commit comments

Comments
 (0)