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

Remove unused/broken references to util_dynamic_array.h #141

Conversation

johnmcfarlane
Copy link
Contributor

I assume that external sources of util_dynamic_array.h still exist. If not, I'm happy to remove the preprocessor macro related to this also.

@johnmcfarlane
Copy link
Contributor Author

Suggestion: to help make the Git history more readable, I recommend rebasing changes on the main branch before merging them.

@ckormanyos
Copy link
Owner

Hi @johnmcfarlane what I did was pull util::dynamic_array into the header file uintwide_t. And the uintwide_t class needs util::dynamic_array for very large digit counts.

If the project has an external source of util::dynamic_array, then WIDE_INTEGER_DISABLE_IMPLEMENT_UTIL_DYNAMIC_ARRAY should be defined and the header uintwide_t will not implement its own copy of util::dynamic_array.

@ckormanyos
Copy link
Owner

So your change is fine for the CMake build, but the proprocessor maccro needs to remain. Personally, i'm not very happy with the way i use util::dynamic_array and wish that C++ would offer such a fixed-size array class with dynamic, one-shot, fixed-width allocation. Maybe there is such a container by now, but I personally am not aware of it.

@ckormanyos ckormanyos merged commit a403566 into ckormanyos:master Nov 11, 2021
@johnmcfarlane
Copy link
Contributor Author

@ckormanyos yes there are many nearly-the-same containers and proposals for many of them. However vector covers so much area that the are not super-urgent.

Have you considered vector? I know it's larger than {pointer, size} but if you were to implement an elastic number which is growing exponentially (e.g. many successive calls to n *= 42;), then this would involve fewer dynamic allocations.

Alternatively, does unique_ptr<T[]> help in any way?

@johnmcfarlane johnmcfarlane deleted the clean-up-util_dynamic_array-references branch November 11, 2021 11:12
@ckormanyos
Copy link
Owner

Have you considered vector? I know it's larger than {pointer, size} ...

Yes John, this is actually a long story.

Believe it or not, in fact, some of the systems that I originally used (and one system I still use today) with uintwide_t do not have STL implementations --- so no std::vector available either. So I opted to write a custom container as well as a bunch of easy-to-write other STL stuff like array, etc. With these methods, all my projects and samples --- even for the most tiny microcontrollers --- work fine.

In cnl, I might recommend to eventually kick out the self-written container (or switch it for a replacement enabled/disabled via preprocessor option) and go with a constant-sized kind of a std::vector. When doing this sort of thing, I usually end up wrapping std::vector with a templated Size parameter.

The code using the container should be container independent. What we ultimately do in cnl is not yet known to me. But at least I got the whole story out there.

@johnmcfarlane
Copy link
Contributor Author

Got it. Then can I suggest the adaptor pattern as used by std::queue where you pass the container type into the number type as a template parameter?

I would recommend you split up the type into two types - roughly along the lines of P1889's bounded and unbounded types. Here's an example of how you might go about this without duplicating too much code.

@ckormanyos
Copy link
Owner

ckormanyos commented Nov 15, 2021

... recommend you split up the type into two types - roughly along the lines of P1889's bounded and unbounded types. Here's an example of how you might go about this without duplicating too much code.

Hi @johnmcfarlane I am confused how/if there is a template parameter for is_signed/is_unsigned? Is that the parameter S in the P1889? What is the type of S if it even is sign-related? I had expected something like template parameter bool is_unsigned = false.

@johnmcfarlane
Copy link
Contributor Author

Please see separate issue for latest CE prototype. It has a bool parameter. It's up to you if that's the most appropriate interface. I'd say it's a good fit of you firmly believe that a sequence of unsigned limbs is the best representation by a fair distance. Because then how do you know if the ripper is signed otherwise?

@johnmcfarlane
Copy link
Contributor Author

Here's the thread with the example: #91 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants