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

Unified Operator Proposal for int, float, and bigint #6673

Open
mununki opened this issue Mar 13, 2024 · 1 comment
Open

Unified Operator Proposal for int, float, and bigint #6673

mununki opened this issue Mar 13, 2024 · 1 comment

Comments

@mununki
Copy link
Member

mununki commented Mar 13, 2024

Background

In the current ReScript design, operators for int and float types are distinct, requiring developers, especially those familiar with JavaScript, to learn and remember separate operators for these types. This distinction not only adds a learning curve for newcomers but also complicates the language's simplicity ethos. As the JavaScript ecosystem evolves and considers wider adoption of BigInt for larger integer operations, this approach might necessitate introducing yet another set of operators, further complicating the situation.

Proposal

I propose a syntax layer adjustment to allow a unified operator set for arithmetic operations across int, float, and potentially BigInt types. The goal is to streamline the developer experience by reducing the cognitive load and making the language more approachable for newcomers without introducing significant changes to the type checker.

Key Points:

  • Unified Operators: Use a single set of arithmetic operators that work intuitively across int, float, and BigInt types, similar to how JavaScript handles arithmetic operations without requiring different operators for different numeric types.
  • Minimal Changes to Type Checker: Keep changes to the type checking logic minimal.
  • Backward Compatibility: Ensure that these changes do not break existing codebases. A phased approach or compiler flags could be considered for a transition period.
@mununki
Copy link
Member Author

mununki commented Mar 13, 2024

Discussions: #6670 (comment) #6670 (comment)

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

No branches or pull requests

1 participant