[swift-evolution] Beef up Imports
pyry.jahkola at iki.fi
Sun Dec 27 09:53:01 CST 2015
> T.J. Usiyan <griotspeak at gmail.com> wrote:
> import Foo using (bar, Baz, qux, waldo as fred) // a "whitelist import"
> import Foo hiding (bar, Baz, qux, waldo as fred) // a "blacklist import"
> Is nice but `hiding… (waldo as fred)` is confusing. Am I hiding waldo?
You're right That's also what Robert pointed out in his reply. The way I thought it is "hide waldo, naming it as fred instead." I like the symmetry of it with the `import-using` statement, but true, it doesn't read well.
Hmm, given that keywords are still up in the air, why not s/hiding/except/? Then we'd have:
import Foo using (bar, Baz, qux, waldo as fred) // a "whitelist import"
import Foo except (bar, Baz, qux, waldo as fred) // a "blacklist import"
The double meaning of "except" in the phrases "except X" (without X) and "except X as Y" (everything else as is, but X as Y) would work.
And no one would write the silly sounding empty `import Foo except ()` anyway because the plain `import Foo` works too.
> It is also strange to look in that list for things that I am hiding and things that I am importing. Context switches after the item that I am importing because `as` follows the item in question.
I'd say that's entirely ok. You could by convention e.g. keep a habit of listing all renames together (in the end of the list, or in another import-except statement), which could be checked by a linter if someone wanted.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution