Pitch: Introduce #module to get the current module name

I see. I think there's room for both tbh! #module is important because the #magicIdentifiers are the one place where you can get information from your caller.

Ie. if say we have two modules: App and Framework. If in the Framework module we have:

public func printCallerModule(_ module: String = #module) {
    print(module)
}

And in App we do

import Framework

printCallerModule()

Then it will print App because the #magicIdentifiers get evaluated in the caller's context. If we had a (hypothetical) Module.Type and did public func printCallerModule(_ module: String = "\(Module.Type)") then the above would print Framework which isn't what we need.

1 Like