This is mainly targeted at the if / when / unless macros, but in theory it could apply to user-defined macros as well.
The user is going to use if a ton, and I don't want us calling out to GDScript every time. That just slows the compiler to a crawl. if is defined as follows.
(defmacro if (cnd t &opt f)
`(cond
(,cnd ,t)
(#t ,f)))
Here's my proposal. If a macro satisfies all of the following conditions, then it is eligible for call subversion.
The macro body consists of one single statement, which is either a quasiquote or a quote call.
Within the quoted body, all unquotes are of the form (unquote variable-name) where variable-name is the name of an argument to the macro.
In this case, we take the extremely simply macro body and interpret it in Rust using our existing quasiquoting mechanism, avoiding the GDScript macro call altogether.
This is mainly targeted at the
if
/when
/unless
macros, but in theory it could apply to user-defined macros as well.The user is going to use
if
a ton, and I don't want us calling out to GDScript every time. That just slows the compiler to a crawl.if
is defined as follows.Here's my proposal. If a macro satisfies all of the following conditions, then it is eligible for call subversion.
quasiquote
or aquote
call.(unquote variable-name)
wherevariable-name
is the name of an argument to the macro.In this case, we take the extremely simply macro body and interpret it in Rust using our existing quasiquoting mechanism, avoiding the GDScript macro call altogether.