8000 Update syntax by Yu-zh · Pull Request #2285 · moonbitlang/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
8000

Update syntax #2285

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 7 commits into from
Jun 17, 2025
Merged

Update syntax #2285

merged 7 commits into from
Jun 17, 2025

Conversation

Yu-zh
Copy link
Collaborator
@Yu-zh Yu-zh commented Jun 16, 2025

No description provided.

@Yu-zh Yu-zh changed the title Update syntax 616 Update syntax Jun 16, 2025
Copy link
peter-jerry-ye-code-review bot commented Jun 16, 2025 • 8000 ;
Redundant Interface Declarations

Category
Maintainability
Code Snippet
fn[T] copy(Array[T]) -> Array[T]
fn[T] copy(T[T]) -> T[T]
Recommendation
Remove redundant function declarations when there are corresponding method declarations (e.g. fn T::copy)
Reasoning
Having both top-level function and method declarations for the same functionality creates maintenance overhead and potential confusion. The method declaration should be sufficient.

Improved Type Alias Syntax

Category
Maintainability
Code Snippet
pub typealias View[T] = ArrayView[T]
// Changed to:
pub typealias ArrayView as View
Recommendation
Use the new as syntax for type aliases which is more concise and clearer
Reasoning
The new syntax makes the aliasing relationship more explicit while reducing verbosity. It better expresses the intent of creating an alternative name.

Parentheses Around Operator Precedence

Category
Correctness
Code Snippet
a / b |> ignore
// Changed to:
(a / b) |> ignore
Recommendation
Add parentheses around operations feeding into the pipeline operator to make precedence explicit
Reasoning
Without parentheses, operator precedence might be ambiguous or incorrect. Adding parentheses makes the evaluation order clear and prevents potential bugs.

@Yu-zh Yu-zh force-pushed the update-syntax-616 branch from 7d57fb0 to 511f6d3 Compare June 16, 2025 08:00
@Yu-zh Yu-zh force-pushed the update-syntax-616 branch from 5055a5b to d64ec51 Compare June 17, 2025 08:12
@myfreess myfreess force-pushed the update-syntax-616 branch from d64ec51 to d577131 Compare June 17, 2025 10:11
@myfreess myfreess force-pushed the update-syntax-616 branch from ef25c04 to 773b678 Compare June 17, 2025 11:11
@myfreess myfreess merged commit a33e8e1 into main Jun 17, 2025
15 of 16 checks passed
@myfreess myfreess deleted the update-syntax-616 branch June 17, 2025 11:20
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