Hi! I am wondering if there is any kind of correct syntax for importing a macro package and then calling one of those macros along with the module as a "namespace". For example:
import MyMacro
let a = 17
let b = 25
let (result, code) = #MyMacro.stringify(a + b)
Fails with a No macro named 'MyMacro' error.
What happens if I import two macro packages that declare two different macros with the same name? If the two packages declared a type (like a struct or class), I could qualify that type at compile time with M1.Foo or M2.Foo… but I do not know if there is a way to achieve this with macros.
Is the "best practice" for macro engineers to build macros with non-generic sounding names? Or are we expected to add our macro package name to every macro declared like we did in ObjC days (where public macro stringify becomes public macro MyMacroStringify)?
Unfortunately the language grammar doesn't support invoking freestanding macros with a fully-qualified name; it only parses '#' + identifier, not '#' + MemberAccessExpr.
I suspect (and hope) that's just an oversight and that there's no fundamental reason it couldn't be allowed. Especially since attached macros can be used that way; @ModuleName.MacroName is perfectly valid.
I brought this up at the time and it was pointed out that e.g. #file.count is valid today and means (#file).count. So we’ll need a different syntax, unfortunately.
This is a very similar problem to Pitch: Fully qualified name syntax and I would love if we end up with a single syntax that can be used for both.