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
Optimization of types #3978
Comments
Comment author: @xavierleroy This representation optimization has been considered before. Unclear to me |
Comment author: Christophe type color = Color of int but... module Color : sig let dark c = Color.of_int (Color.to_int c + 1) this is a more complex code just for efficiency ! This makes difficult to use primitive types without merging them (just say type color = int). |
Comment author: n8gray I think Christophe makes the case for this pretty well, but I just wanted to add my support. I keep wanting to use this sort of construct for units: type cm = Cm of float I would argue that guaranteeing an efficient representation for this would lead to more reliable software, since programmers wouldn't have to worry about killing performance with needless boxing ops, even in low-level math code. Update: Fixed my math! (blush) |
Comment author: @mshinwell Fixed by #606 |
Original bug ID: 3978
Reporter: Christophe
Assigned to: @mshinwell
Status: resolved (set by @mshinwell on 2016-12-06T21:26:51Z)
Resolution: fixed
Priority: low
Severity: feature
Version: 3.09.1
Category: ~DO NOT USE (was: OCaml general)
Monitored by: n8gray nogin
Bug description
When I defined a mono type like
type color = Color of int ;;
all values of type color are integers. But it seems that, even if I compile with ocamlopt, such value are represented within a block. It seems completly useless to do such a representation as there is only one constructor in the color type, as core values are integers, and as typage is a static operation....
So is it a complex optimization, or is there some difficulty that I do not see that prevent such an optimization ?
Thank you !
The text was updated successfully, but these errors were encountered: