Skip to content

Commit 2358206

Browse files
quinnjKristofferC
authored andcommitted
Small update to macro keyword doc (#34305)
Note that macros can accept varargs but not kwargs
1 parent 6fc5775 commit 2358206

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

base/docs/basedocs.jl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ resulting expression is substituted directly into the program at the point where
158158
the macro is invoked.
159159
Macros are a way to run generated code without calling [`eval`](@ref Base.eval), since the generated
160160
code instead simply becomes part of the surrounding program.
161-
Macro arguments may include expressions, literal values, and symbols.
161+
Macro arguments may include expressions, literal values, and symbols. Macros can be defined for
162+
variable number of arguments (varargs), but do not accept keyword arguments.
162163
163164
# Examples
164165
```jldoctest
@@ -169,6 +170,14 @@ julia> macro sayhello(name)
169170
170171
julia> @sayhello "Charlie"
171172
Hello, Charlie!
173+
174+
julia> macro saylots(x...)
175+
return :( println("Say: ", \$(x...)) )
176+
end
177+
@saylots (macro with 1 method)
178+
179+
julia> @saylots "hey " "there " "friend"
180+
Say: hey there friend
172181
```
173182
"""
174183
kw"macro"

0 commit comments

Comments
 (0)