Skip to content

stdlib: add Pervasives.int_size#1572

Merged
alainfrisch merged 1 commit intoocaml:trunkfrom
murmour:Pervasives.int_size
Mar 1, 2018
Merged

stdlib: add Pervasives.int_size#1572
alainfrisch merged 1 commit intoocaml:trunkfrom
murmour:Pervasives.int_size

Conversation

@murmour
Copy link
Copy Markdown
Contributor

@murmour murmour commented Jan 17, 2018

Integer size is an important part of arithmetic specification, so it makes sense to have it in Pervasives, for the purpose of improving documentation.

Now, the docstrings for lsl, lsr, and asr are compatible with Js_of_ocaml.

@murmour murmour force-pushed the Pervasives.int_size branch from 581b18d to 71d0ff2 Compare January 17, 2018 02:31
@gasche
Copy link
Copy Markdown
Member

gasche commented Jan 17, 2018

I am not convinced that this value needs to be in Pervasives. On the other hand, the changes to lsl, etc. seem reasonable, but you could do them with > Sys.int_size as well.

@murmour
Copy link
Copy Markdown
Contributor Author

murmour commented Jan 17, 2018

But would it be fine to refer to Sys from Pervasives? This seems like unnecessary semantic dependency.


val int_size : int
(** Size of an integer, in bits. It is 31 (resp. 63) when using the OCaml
compiler on a 32-bit (resp. 64-bit) platform. It may differ for other
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we refer to the target machine/architecture rather than to compilers?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this?

(** Size of an integer, in bits. It is 31 (resp. 63) when using OCaml on a
    32-bit (resp. 64-bit) platform. It may differ for other implementations,
    e.g. it can be 32 bits when compiling to JavaScript.
    @since 4.07.0
*)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine. If you follow @gasche / @dra27 advice and do not
duplicate the value from Sys, you might consider updating the
documentation of Sys.

where [bitsize] is [32] on a 32-bit platform and
[64] on a 64-bit platform.
Right-associative operator at precedence level 8/11. *)
The result is unspecified if [m < 0] or [m > int_size].
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't [int_size] just an alias for [bit_size]?
(If so, the characterization of unspecified
results has changed)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, bit_size = 32 / 64 and int_size = 31 / 63

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course, sorry for the noise.

@dra27
Copy link
Copy Markdown
Member

dra27 commented Jan 17, 2018

I agree with @gasche that it doesn't seem necessary to duplicate the symbol. I don't personally see a problem with documentation referring to modules against the direction of the dependency chain.

@murmour murmour force-pushed the Pervasives.int_size branch from 71d0ff2 to 97aa362 Compare January 17, 2018 13:42
@murmour
Copy link
Copy Markdown
Contributor Author

murmour commented Jan 17, 2018

Alright, I feel convinced that duplicating int_size is unnecessary. The updated PR consists of comment tweaks.

Copy link
Copy Markdown
Member

@damiendoligez damiendoligez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This version looks good.

@alainfrisch
Copy link
Copy Markdown
Contributor

@murmour Can you rebase on trunk?

@alainfrisch alainfrisch self-assigned this Mar 1, 2018
@murmour murmour force-pushed the Pervasives.int_size branch from 97aa362 to 20f39bd Compare March 1, 2018 17:27
@murmour
Copy link
Copy Markdown
Contributor Author

murmour commented Mar 1, 2018

@murmour Can you rebase on trunk?

Done.

@alainfrisch alainfrisch merged commit ae2af89 into ocaml:trunk Mar 1, 2018
EmileTrotignon pushed a commit to EmileTrotignon/ocaml that referenced this pull request Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants