rescript-lang / rescript-lang/rescript

Proposal: Optional "return" as Syntactic Sugar in ReScript 13

Offen
#8,191 7 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
OCaml
Sterne
7.5k
Forks
485
Ø Merge
1 T. 2 Std.
Gemergte PRs (30 T.)
55

Beschreibung

Author: Jonathan Jewell Status: Draft / RFC Goal: Facilitate onboarding for JS/TS developers without compromising ReScript’s functional core.


Overview

Add return as optional syntactic sugar for function expressions. This desugars to the last expression during compilation, with zero semantic or performance impact.

Current ReScript | Proposed (Sugar) | Desugared Output -- | -- | -- let add = (a, b) => a + b | let add = (a, b) => return a + b | let add = (a, b) => a + b

Call to Action

  • If this sounds good, I am offering to:
    • Implement the prototype and draft documentation.
    • Monitor community feedback and report back before ReScript 14.
  • Proposal team:
    • Greenlight: To try it as an experiment, see what the reception is.
    • Feedback: Suggest improvements or dealbreakers.
    • Veto: If the team feels this is misaligned, we can drop it - no hard feelings!

Final Note:

This is not about changing ReScript, but I think it is useful in helping onboard more developers to discover why it is great and helps users implement some of the most basic functions in their language in Rescript. If it does not work or is received poorly, we can kill it without any issue. But in any case, it is optional for use, and - as sugar - and would not anticipate any reason to affect backward compat or future ambitions for the language.


Next Steps:

  1. Discuss in the next core team meeting.
  2. If approved, I’ll open a PR for the prototype.
  3. Interact with the community via an RFC or blog post.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Das Issue nennt keine Dateien, Tests oder Compiler-Einstiegspunkte. Beginne mit der RFC-Diskussion und der geplanten Überprüfung durch das core team; als abgeschlossen würde ein genehmigter Prototyp und ein Entwurf der Dokumentation gelten, gefolgt von Feedback aus der Community.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, ocaml
Bereich
compilers, developer-experience
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.