Rename Complex type or module
stephentyrone opened this issue · comments
For the reasons discussed in this forums thread it would be slightly advantageous to make the Complex type and module have different names. This requires renaming one of them.
This would allow people who want to work with a single concrete complex type to do something like:
typealias Complex = ComplexType<Float> // if we rename the type
typealias Complex = ComplexModule.Complex<Float> // If we rename the module
They would then still be able to get at the generic type as either ComplexType
or ComplexModule.Complex
.
As you can see, renaming the type makes this specific use case a tiny bit neater, but makes the normal generic usage a tiny bit messier (while renaming the module only changes the import statement in routine use, which is less invasive).
More generally, I would like to establish a general policy for how to handle this situation, as I expect it to come up repeatedly in Swift Numerics.
My vote is for renaming the module. There is little precedent for appending Type
at the end of names for generic types, but plenty of precedent for seeking out unique module names, which are essentially not at all constrained by naming guidelines.
I think that it would make more sense to rename the module, since one is more likely to spell out the type more often (especially if one is writing generic code), and so having ComplexType<..>
in many places makes it a little tedious to skim.
@xwu That's basically my feeling as well (but: Type
is purely a strawman suffix here; if someone had a good proposal for a suffix that made more sense, I would consider it).
I also think renaming the modules is better, especially if they will migrate into the standard library.
-
You could use a three letter prefix (similar to the SwiftNIO modules):
import Numerics import NMXBigInt // struct BigInt import NMXComplex // struct Complex import NMXReal // protocol Real
-
You could use the "Swift" prefix:
import SwiftNumerics import SwiftBigInt // struct BigInt import SwiftComplex // struct Complex import SwiftReal // protocol Real
Draft PR using "Numerics" as a placeholder module prefix here: #97
Resolved in 0.0.5 by adding the disambiguating Module suffix to Real and Complex.