-
Notifications
You must be signed in to change notification settings - Fork 9
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
Custom allocation for integers #43
Comments
Hi thanks for your idea! I'm not sure.. If you want a custom allocator, that means you have to add a type parameter to the integer type right? In that case I'm afraid that it will make a huge break change and make the library much less friendly to users. Could you please provide a small snippet of how you would like to implement this feature? (e.g. how you will instrument the structs). With that context, I can have a better idea of how large this change will be. Thanks again! |
My solution would introduce derived integer and rational types that would indeed be parameterized on an allocator type. The derived types would be composed of e.g. an I'm not sure to what degree this would require duplicating existing code. It appears much of it is generated by macros already. Maybe if it was behind an optional feature turned off by default? |
It will be great if additional types (such as Regarding using a feature flag, it's not ideal since feature flags have to be additive (i.e. turning on the flag should not make existing code break) |
Ok, I'll submit a draft PR somewhat soon (in the coming weeks or months). |
Would that acceptable? I think that would be a lot less impactful than introducing an immutable integer type with customizable allocation. |
Your plan sounds good to me. I imagine that signatures of the constructors might change, but it makes a minimal impact to the users of the Regarding the allocator type, what's your opinion on the trait definition? Do you plan to use the |
Yes, exactly this. |
In scryer-prolog I want to allocate integers to a custom garbage-collected arena so that the memory of unreachable (but always immutable) integers and rationals can be implicitly recycled without calling any
Drop
instance. dashu doesn't currently have a means to customize allocation.I'd like to submit a PR to add the feature to dashu, likely by elevating
MemoryAllocation
to a trait whose instance can be specified in theibig!
andubig!
macros among other places, at least until theallocator_api
is merged to stable (probably not for a long while yet).Is this acceptable @cmpute ? Or perhaps there's a way to go about this that I don't know about?
The text was updated successfully, but these errors were encountered: