Skip to content

Rename Complex type or module #94

Closed
@stephentyrone

Description

@stephentyrone
Member

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).

Activity

stephentyrone

stephentyrone commented on Jan 21, 2020

@stephentyrone
MemberAuthor

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.

xwu

xwu commented on Jan 21, 2020

@xwu
Contributor

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.

varungandhi-apple

varungandhi-apple commented on Jan 22, 2020

@varungandhi-apple

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.

stephentyrone

stephentyrone commented on Jan 22, 2020

@stephentyrone
MemberAuthor

@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).

benrimmington

benrimmington commented on Jan 22, 2020

@benrimmington
Contributor

I also think renaming the modules is better, especially if they will migrate into the standard library.

  1. 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
  2. You could use the "Swift" prefix:

    import SwiftNumerics
    import SwiftBigInt   // struct BigInt
    import SwiftComplex  // struct Complex
    import SwiftReal     // protocol Real
stephentyrone

stephentyrone commented on Jan 24, 2020

@stephentyrone
MemberAuthor

Draft PR using "Numerics" as a placeholder module prefix here: #97

stephentyrone

stephentyrone commented on Apr 13, 2020

@stephentyrone
MemberAuthor

Resolved in 0.0.5 by adding the disambiguating Module suffix to Real and Complex.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    policyquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @xwu@stephentyrone@benrimmington@varungandhi-apple

        Issue actions

          Rename Complex type or module · Issue #94 · apple/swift-numerics