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
Positional and keyword arguments are treated differently in code emitted by macros:
# @m1 defines function f with position argument
julia>macrom1()
:(functionf(x=1)
x = x *10end)
end# @m2 defines function g with keyword argument
julia>macrom2()
:(functiong(;x=1)
x = x *10end)
end# in @m1, all occurrences of x are properly replaced by the same gensymmed name
julia>@macroexpand@m1
:(function Main.f(var"#84#x"=1)
#= REPL[11]:2 =##= REPL[11]:3 =#var"#84#x"=var"#84#x"*10end)
# in @m2, the x symbol in signature remains as-is, ...
julia>@macroexpand@m2
:(function Main.g(; x =1)
#= REPL[12]:2 =##= REPL[12]:3 =#var"#85#x"=var"#85#x"*10end)
# ..., leading to the obvious error:
julia>@m2
julia>g()
ERROR: UndefVarError:`x` not defined
I believe the positional argument handling is correct (m1 above), but not kwargs handling (m2 above).
The text was updated successfully, but these errors were encountered:
Positional and keyword arguments are treated differently in code emitted by macros:
I believe the positional argument handling is correct (m1 above), but not kwargs handling (m2 above).
The text was updated successfully, but these errors were encountered: