jackfirth / resyntax

A Racket refactoring engine
Apache License 2.0
56 stars 10 forks source link

Suggest `cond` instead of `if` with `begin` or `let` #183

Closed jackfirth closed 1 year ago

jackfirth commented 1 year ago

This code:

(if condition
    (let ([x 1])
      (f x))
    (begin
      (g)
      (h)))

Can be expressed more clearly using cond and define:

(cond
  [condition
   (define x 1)
   (f x)]
  [else
   (g)
   (h)])

Resyntax should suggest using cond instead of if when at least one arm of the if uses begin or a let that can be rewritten to define.