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

Sync docs for js_math.ml #5441

Conversation

nkrkv
Copy link
Contributor

@nkrkv nkrkv commented Jun 16, 2022

No description provided.

Comment on lines +488 to 499
(**
Raises the given base to the given exponent. (Arguments and result are
integers.) See
[`Math.pow`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow)
on MDN.

```res example
Js.Math.pow_int(~base=3, ~exp=4) == 81
```
*)
external pow_int : base:int -> exp:int -> int = "pow" [@@bs.val] [@@bs.scope "Math"]
[@@deprecated "use `power_float` instead, the return type may be not int"]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Inconsistent gotcha here. The pow_int function is deprecated but docs in mdx do not mention it. For now, I copied the docs as is, without the deprecation notice.

However, looking at other similar cases (unsafe_ceil_int / ceil_int, unsafe_round, unsafe_trunc) to be consistent:

  • pow_int should be renamed to unsafe_pow_int
  • The documentation should include the standard explanation of range issues¹
  • A new function pow_int which is an alias to the unsafe_pow_int should be introduced and deprecated immediatelly
  • pow_int docs should say “please, use unsafe_pow_int

¹

This function may return values not representable by int, whose range is -2147483648 to 2147483647. This is because, in JavaScript, there are only 64-bit floating point numbers, which can represent integers in the range ±(253-1) exactly.

Should I do it now or it is a task for the latter, when the whole docs PR settles down?

Copy link
Member

Choose a reason for hiding this comment

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

maybe let's have a separate issue and tackle this after the transition? There shouldn't be any semantic changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. So for now, I guess the PR is ready for merge.

@nkrkv nkrkv mentioned this pull request Jun 16, 2022
35 tasks
@ryyppy ryyppy merged commit 8d7850c into rescript-lang:sync-belt-doc-headers Jun 18, 2022
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.

2 participants