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

Feature request: polymorphic comparison of big_int #5375

Closed
vicuna opened this issue Oct 12, 2011 · 1 comment
Closed

Feature request: polymorphic comparison of big_int #5375

vicuna opened this issue Oct 12, 2011 · 1 comment

Comments

@vicuna
Copy link

vicuna commented Oct 12, 2011

Original bug ID: 5375
Reporter: edmcman
Status: closed (set by @xavierleroy on 2011-10-15T08:47:22Z)
Resolution: not fixable
Priority: normal
Severity: feature
Category: ~DO NOT USE (was: OCaml general)
Monitored by: @yakobowski

Bug description

compare and other polymorphic comparison functions are not defined for big_int types. We use big_ints in an abstract syntax tree type. Since compare does not work with big ints, we must manually write our own comparison functions, which is very unsatisfying (and tedious).

@vicuna
Copy link
Author

vicuna commented Oct 15, 2011

Comment author: @xavierleroy

I agree this is a annoying problem with big_int, but I'm afraid there is no solution: big_int is a mixed Caml/C datatype, with a Caml record encapsulating a sign, a size and a low-level "nat" type implemented in C. The custom comparison functions would have to be attached to the big_int type itself (attaching them to the "nat" type just gives the wrong results), and there is no way to do so in OCaml.

I can only recommend that you replace big_int by Zarith in your code:
http://forge.ocamlcore.org/projects/zarith/
Not only Zarith is faster and more space-efficient than big_int, but it also supports polymorphic comparisons perfectly.

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

No branches or pull requests

1 participant