rescript-lang / rescript-compiler

The compiler for ReScript.
https://rescript-lang.org
Other
6.65k stars 440 forks source link

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

Open mununki opened 5 months ago

mununki commented 5 months ago

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:

mununki commented 5 months ago

Discussions: https://github.com/rescript-lang/rescript-compiler/pull/6670#issuecomment-1988132107 https://github.com/rescript-lang/rescript-compiler/pull/6670#issuecomment-1989241263