8000 hongbo/rational docs by bobzhang · Pull Request #2298 · moonbitlang/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Conversation

bobzhang
Copy link
Contributor
  • MoonAgent: add docs
  • update
  • moon info

Copy link
Documentation examples could be inconsistent in type suffixes

Category
Maintainability
Code Snippet
// Create 3/4
let r1 = @rational.new(3L, 4L)
Recommendation
Be consistent with the use of 'L' suffix in examples. Either use it everywhere or provide a note about optional type suffixes
Reasoning
Some examples use 'L' suffix for Int64 literals while others don't, which could confuse users about when it's required

Complex example in division operation uses nested pattern matching

Category
Maintainability
Code Snippet
match (a, b) {
(Some(x), Some(y)) => {
let result = x / y
inspect(result, content="3/4")
}
_ => ()
}
Recommendation
Simplify example to use unwrap() like other examples:

let a = @rational.new(1L, 2L).unwrap() // 1/2
let b = @rational.new(2L, 3L).unwrap() // 2/3
let result = a / b // 3/4
inspect(result, content="3/4")

Reasoning
Documentation examples should be as simple as possible while still demonstrating the functionality. The current pattern matching adds unnecessary complexity

Missing error documentation for division by zero in op_div implementation

Category
Correctness
Code Snippet
pub impl Div for T with op_div(self : T, other : T) -> T {
Recommendation
Add documentation about division by zero behavior:

///
/// Note: This operation assumes the divisor is non-zero, as the type T can only
/// be constructed with non-zero denominators via the `new` function.
///

Reasoning
Critical behavior assumptions should be documented, especially for mathematical operations with well-known edge cases

@bobzhang bobzhang enabled auto-merge (rebase) June 19, 2025 13:03
@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 7384

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.002%) to 89.888%

Totals Coverage Status
Change from base Build 7382: -0.002%
Covered Lines: 8507
Relevant Lines: 9464

💛 - Coveralls

@bobzhang bobzhang merged commit 4e16a1c into main Jun 19, 2025
16 checks passed
@bobzhang bobzhang deleted the hongbo/rational_docs branch June 19, 2025 13:08
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
0