Skip to content

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

Closed
@mununki

Description

@mununki

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions