reasonml / reasonml/reason

Implicit blocks for else.

Open
#2,477 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
OCaml
Stars
10.3k
Forks
438
PR merge metrics
No merged PRs in 30d

Description

Many people want the benefits of early return. There's a way to get many of them without the complexity of early return:

We can simply allow the else blocks to not be wrapped in { }.
Instead of this:

let fn = (shouldRun, name) => {
  if (!shouldRun()) {
    []
  } else {
  	if (name == "test") {
      []
    } else {
      if (String.length(name) > 80) {
        ["name too long"]
      } else {
        []    
      };
    };
  };
};

We could allow:

let fn = (shouldRun, name) => {
  if (!shouldRun()) {
    []
  } else
  if (name == "test") {
    []
  } else
  if (String.length(name) > 80) {
    ["name too long"]
  } else {
    []
  }
};

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files, tests, or entry points. Start by locating the Reason syntax and parser handling if/else expressions, then review existing grammar tests. Done means the unbraced else-if form is accepted while the existing braced form continues to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.