8000 chore: use arrow functions in @array and @list by FlyCloudC · Pull Request #2362 · moonbitlang/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

chore: use arrow functions in @array and @list #2362

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

Merged
merged 2 commits into from
Jun 26, 2025

Conversation

FlyCloudC
Copy link
Contributor

No description provided.

Copy link
peter-jerry-ye-code-review bot commented Jun 26, 2025
Consistent function syntax modernization

Category
Maintainability
Code Snippet

  • let arr = Array::makei(3, fn(i) { i * 2 })
  • let arr = Array::makei(3, i => i * 2)
    Recommendation
    The change is good, continue with this pattern but add documentation about the arrow function syntax in language docs
    Reasoning
    The arrow function syntax makes the code more concise and readable, especially for simple lambda functions. This is consistent with modern programming language conventions.
Multi-parameter arrow functions may need parentheses for clarity

Category
Maintainability
Code Snippet

  • let concat = l2.scan_right(fn(acc, x) { x + acc }, init="")
  • let concat = l2.scan_right((acc, x) => x + acc, init="")
    Recommendation
    Keep parentheses around multiple parameters for readability
    Reasoning
    Parentheses around multiple parameters help visually separate the parameter list from the arrow, improving readability. The changes already follow this convention which is good.
Complex closures may still warrant traditional function syntax

Category
Correctness
Code Snippet
fixed_test_sort(arr => fixed_bubble_sort_by(
{ array: arr, start: 0, end: arr.length() },
(a, b) => a - b
))
Recommendation
Consider keeping fn syntax for complex multi-line functions to maintain readability
Reasoning
While arrow syntax improves readability for simple functions, complex functions with multiple lines or nested logic may be clearer with traditional function syntax and explicit braces.

@coveralls
Copy link
Collaborator
coveralls commented Jun 26, 2025

Pull Request Test Coverage Report for Build 76

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 89.003%

Totals Coverage Status
Change from base Build 69: 0.0%
Covered Lines: 3464
Relevant Lines: 3892

💛 - Coveralls

@FlyCloudC FlyCloudC changed the title chore(array): use arrow functions chore: use arrow functions in @array and @list Jun 26, 2025
@bobzhang bobzhang merged commit 070c469 into moonbitlang:main Jun 26, 2025
10 checks passed
@FlyCloudC FlyCloudC deleted the chore-arrow branch July 2, 2025 10:48
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.

3 participants
0