jackfirth / resyntax

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

Suggest `for*/list` instead of appending `for/list` #217

Closed jackfirth closed 11 months ago

jackfirth commented 11 months ago

Saw this code today:

(apply
 append
 (for/list ([k (in-list keys)])
   (get k)))

I think this gets a little easier to read if it's migrated to use for*/list like this:

(for*/list ([k (in-list keys)]
            [v (in-list (get k))])
  v)

This only works for loops where the body is a single expression since the entire body gets shoved into the [v (in-list ...)] clause. It also only works for for/list loops with one clause, though that restriction doesn't apply to for*/list loops.