jackfirth / jackfirth/resyntax

impossible wish: unravel complex or-and expressions

Open
#228 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

new lint
Dominant language
Racket
Stars
70
Forks
11
PR merge metrics
No merged PRs in 30d

Description

     (or (and b (weak-box-value b))
         (let ([e (make-cached-element style content key)])
           (hash-set! element-cache key (make-weak-box e))
           e))

could be much better communicated with:

     (cond
       [b (weak-box-value b)]
       [else
        (let ([e (make-cached-element style content key)])
          (hash-set! element-cache key (make-weak-box e))
          e)])

which then opens an opportunity for let-in-cond simplification rule to kick in.

It's an impossible wish because the two code are not quite semantically equivalent generally. They are equivalent here though, because (weak-box-value b) is guaranteed to be non #f.

Contributor guide

Open the contributing guide

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 refactoring rules for complex or-and expressions and let-in-cond simplification, then determine how the engine can establish the non-#f guarantee. Done means the transformation applies only when the expressions are semantically equivalent and is covered by tests.

Written by the indexing model from the issue text.

Assessment

Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.