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

Natural<T> from X #78

Closed
oscbyspro opened this issue Aug 28, 2024 · 3 comments
Closed

Natural<T> from X #78

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

Comments

@oscbyspro
Copy link
Owner

oscbyspro commented Aug 28, 2024

I could use a (natural ≥ 1) and a (natural ≥ 2) guarantee to hoist preconditions in places like (#77). Positive<T> and Radix<T> seem like nice candidates. I thought of names like Natural1<T> and Natural2<T> but I want all trusted input types to be meaningful. You can express (natural ≥ 1) as Positive<some FiniteInteger>. All binary integers can be reinterpreted as a same-size finite integer, so it would be available in all contexts as an unsafe option (at a minimum).

@oscbyspro oscbyspro added addition oh, so shiny! maybe to do, or not to do? labels Aug 28, 2024
@oscbyspro
Copy link
Owner Author

oscbyspro commented Aug 29, 2024

Well, the Positive<some FiniteInteger> reinterpretation idea is not great. It doesn't always give you a value of Self, so you have to make things unnecessarily generic and manage that.

@oscbyspro
Copy link
Owner Author

oscbyspro commented Aug 29, 2024

Perhaps natural integer suffixes could be modeled using Integer generic parameters.

struct Natural<let LowerBound: Int, Value: BinaryInteger> { }

@oscbyspro oscbyspro changed the title Positive<T> and/or Radix<T> Natural<T> from X Aug 29, 2024
@oscbyspro
Copy link
Owner Author

oscbyspro commented Aug 29, 2024

I think less is more when it comes to these types. Meh.

@oscbyspro oscbyspro closed this as not planned Won't fix, can't repro, duplicate, stale Aug 29, 2024
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