Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Between Numeric and BinaryInteger #93

Open
oscbyspro opened this issue Sep 28, 2023 · 3 comments
Open

Between Numeric and BinaryInteger #93

oscbyspro opened this issue Sep 28, 2023 · 3 comments
Labels
addition oh, so shiny! maybe to do, or not to do?

Comments

@oscbyspro
Copy link
Owner

oscbyspro commented Sep 28, 2023

I'd like to have a protocol that encompasses Signed<Magnitude> without shoehorning it down the binary integer protocol hierarchy. I imagine something like a numeric-but-divisible-and-convertible-thing-y. I haven't thought of the requirements yet, this is more like a todo-note.

@oscbyspro oscbyspro added the addition oh, so shiny! label Sep 28, 2023
@oscbyspro
Copy link
Owner Author

I'd also like to avoid making it integer specific, because that would make the un/signed integer protocols confusing (as they are binary).

@oscbyspro oscbyspro changed the title Between Numeric & BinaryInteger Something between Numeric and BinaryInteger Sep 28, 2023
@oscbyspro oscbyspro added the maybe to do, or not to do? label Sep 28, 2023
@oscbyspro
Copy link
Owner Author

oscbyspro commented Oct 4, 2023

Hm. Most of the Signed<Magnitude> things I want to generalize are integer things, so I guess it would have to be integer related. Maybe I could call it something like basic or primitive since the un/signed protocols have established that binary is the default.

@oscbyspro oscbyspro changed the title Something between Numeric and BinaryInteger Between Numeric and BinaryInteger Oct 4, 2023
@oscbyspro oscbyspro added this to the v0.14.0 milestone Oct 4, 2023
@oscbyspro
Copy link
Owner Author

oscbyspro commented Oct 4, 2023

There are some annoying things that come with trying to insert non-leaf protocols. Like, you get ambiguities if you try to customize existing BinaryInteger methods. It can be solved with additional overloads, however:

extension String {
    init(_ source: some NBKPlainInteger,                 radix: Int = 10, uppercase: Bool = false) { ... }
    init(_ source: some NBKPlainInteger & BinaryInteger, radix: Int = 10, uppercase: Bool = false) { ... }
}

@oscbyspro oscbyspro removed this from the v0.14.0 milestone Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition oh, so shiny! maybe to do, or not to do?
Projects
None yet
Development

No branches or pull requests

1 participant