I recently learned about a disambiguation tool when importing modules in swift:
import (struct|class|protocol|var|let|enum|protocol|typealias) Module.Symbol
So I'm working on reducing the blanket imports and only importing the bare minimum of what I need. No sense importing all of Foundation/Glibc if I'm only using 1 or two things right? (Plus I come from a Python background and I prefer to only import exactly what I need)
Unfortunately, I've ran into two issues I'm unsure of how to solve without going back to importing entire modules.
- The C stat(2) module includes both a
statfunction and a
I would expect that when importing with
import func Glibc.stat it would be able to correctly identify the right stat symbol, especially since trying to
import func a non-function symbol will result in an error. I'd also expect
import struct Glibc.stat to work for more or less the same reason.
However, both fail with the error
ambiguous name 'stat' in module Glibc.
I also would expect to be able to specify the function signature to be able to disambiguate which symbol should be used.
Since I can do things like this:
import Glibc let openFile = Glibc.open(_:_:) let openFileWithMode = Glibc.open(_:_:_:)
I would expect to be able to do this:
import func Glibc.stat(_:_:)
But that also fails (with a bunch of errors).
Which brings me to my next issue...
- What is going on here?
import func Glibc.open // Both these lines error with `Use of unresolved identifier 'open'` let openFile = open(_:_:) let openFileWithMode = open(_:_:_:)
import func Glibc.open // This line fails with `ambiguous use of 'open'` let openFile = open
How do I resolve ambiguity in a disambiguation tool?