Conversation
rfindler
reviewed
Jan 16, 2026
| (define win-label (and (is-a? window window<%>) (send window get-label))) | ||
| (equal? label win-label)] | ||
| [else #f]) | ||
| (list window)] |
Internal definitions are recommended instead of `let` expressions, to reduce nesting.
This `map` operation can be replaced with a `for/list` loop.
Internal definitions are recommended instead of `let` expressions, to reduce nesting.
Use the `#:when` keyword instead of `when` to reduce loop body indentation.
Nested `when` expressions can be merged into a single compound `when` expression.
The `instantiate` form is for mixing positional and by-name constructor arguments. When no positional arguments are needed, use `new` instead.
This named `let` expression is equivalent to a `for` loop that uses `in-range`.
Use the `#:unless` keyword instead of `unless` to reduce loop body indentation.
fbfb661 to
194e2da
Compare
Member
|
I removed the (IMO) questionable commit. |
Contributor
There was a problem hiding this comment.
Resyntax analyzed 7 files in this pull request and has added suggestions.
Comment on lines
+28
to
+35
| (let loop ([dy (- (/ quadrant-size 2))]) | ||
| (when (< dy h) | ||
| (send dc set-alpha 1) | ||
| (send dc set-brush palaka-color 'solid) | ||
| (send dc draw-rectangle dx dy quadrant-size quadrant-size) | ||
| (send dc set-brush "white" 'solid) | ||
| (draw-one-palaka dc dx dy) | ||
| (loop (+ dy quadrant-size))))) |
Contributor
There was a problem hiding this comment.
named-let-loop-to-for-in-range: This named let expression is equivalent to a for loop that uses in-range.
Suggested change
| (let loop ([dy (- (/ quadrant-size 2))]) | |
| (when (< dy h) | |
| (send dc set-alpha 1) | |
| (send dc set-brush palaka-color 'solid) | |
| (send dc draw-rectangle dx dy quadrant-size quadrant-size) | |
| (send dc set-brush "white" 'solid) | |
| (draw-one-palaka dc dx dy) | |
| (loop (+ dy quadrant-size))))) | |
| (for ([dy (in-range (- (/ quadrant-size 2)) h quadrant-size)]) | |
| (send dc set-alpha 1) | |
| (send dc set-brush palaka-color 'solid) | |
| (send dc draw-rectangle dx dy quadrant-size quadrant-size) | |
| (send dc set-brush "white" 'solid) | |
| (draw-one-palaka dc dx dy))) |
Debugging details
Textual replacement
(line-replacement
#:new-lines
'#(" (for ([dy (in-range (- (/ quadrant-size 2)) h quadrant-size)])"
" (send dc set-alpha 1)"
" (send dc set-brush palaka-color 'solid)"
" (send dc draw-rectangle dx dy quadrant-size quadrant-size)"
" (send dc set-brush \"white\" 'solid)"
" (draw-one-palaka dc dx dy)))")
#:original-lines
'#(" (let loop ([dy (- (/ quadrant-size 2))])"
" (when (< dy h)"
" (send dc set-alpha 1)"
" (send dc set-brush palaka-color 'solid)"
" (send dc draw-rectangle dx dy quadrant-size quadrant-size)"
" (send dc set-brush \"white\" 'solid)"
" (draw-one-palaka dc dx dy)"
" (loop (+ dy quadrant-size)))))")
#:start-line 28)Syntactic replacement
(syntax-replacement
#:introduction-scope #<procedure:...and/syntax-local.rkt:148:2>
#:new-syntax
#<syntax:/home/runner/.local/share/racket/9.1.0.1/pkgs/resyntax/default-recommendations/loops/named-let-loopification.rkt:40:2 (for ((dy (in-range (- (/ quadrant-size 2)) h quadrant-size))) (send dc set-alpha 1) (send dc set-brush palaka-color (quote solid)) (send dc draw-rectangle dx dy quadrant-size quadrant-size) (send dc set-brush "white" (quote solid)) (draw-one-palaka dc ...>
#:original-syntax
#<syntax:drracket-core-lib/drracket/private/palaka.rkt:28:4 (let loop ((dy (- (/ quadrant-size 2)))) (when (< dy h) (send dc set-alpha 1) (send dc set-brush palaka-color (quote solid)) (send dc draw-rectangle dx dy quadrant-size quadrant-size) (send dc set-brush "white" (quote solid)) (draw-one-palaka dc dx dy) ...>
#:source
(file-source
#<path:/home/runner/work/drracket/drracket/drracket-core-lib/drracket/private/palaka.rkt>)
#:uses-universal-tagged-syntax? #f)
Comment on lines
+127
to
+133
| (if (<= counter 0) | ||
| (fail) | ||
| (let ([result (pred)]) | ||
| (or result | ||
| (begin | ||
| (sleep step) | ||
| (loop (- counter step)))))))) |
Contributor
There was a problem hiding this comment.
if-let-to-cond: cond with internal definitions is preferred over if with let, to reduce nesting
Suggested change
| (if (<= counter 0) | |
| (fail) | |
| (let ([result (pred)]) | |
| (or result | |
| (begin | |
| (sleep step) | |
| (loop (- counter step)))))))) | |
| (cond | |
| [(<= counter 0) (fail)] | |
| [else | |
| (define result (pred)) | |
| (or result | |
| (begin | |
| (sleep step) | |
| (loop (- counter step))))]))) |
Debugging details
Textual replacement
(line-replacement
#:new-lines
'#(" (cond"
" [(<= counter 0) (fail)]"
" [else"
" (define result (pred))"
" (or result"
" (begin"
" (sleep step)"
" (loop (- counter step))))])))")
#:original-lines
'#(" (if (<= counter 0)"
" (fail)"
" (let ([result (pred)])"
" (or result"
" (begin"
" (sleep step)"
" (loop (- counter step))))))))")
#:start-line 127)Syntactic replacement
(syntax-replacement
#:introduction-scope #<procedure:...and/syntax-local.rkt:148:2>
#:new-syntax
#<syntax:/home/runner/.local/share/racket/9.1.0.1/pkgs/resyntax/default-recommendations/let-replacement/cond-let-replacement.rkt:47:2 (cond ((<= counter 0) (fail)) (else (define result (pred)) (or result (begin (sleep step) (loop (- counter step))))))>
#:original-syntax
#<syntax:drracket-test/tests/drracket/private/no-fw-test-util.rkt:127:4 (if (<= counter 0) (fail) (let ((result (pred))) (or result (begin (sleep step) (loop (- counter step))))))>
#:source
(file-source
#<path:/home/runner/work/drracket/drracket/drracket-test/tests/drracket/private/no-fw-test-util.rkt>)
#:uses-universal-tagged-syntax? #f)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resyntax fixed 20 issues in 7 files.
unless-expression-in-for-loop-to-unless-keywordlet-to-definemap-to-forwhen-expression-in-for-loop-to-when-keywordand-let-to-condnamed-let-loop-to-for-in-rangenested-when-to-compound-whencond-let-to-cond-defineinstantiate-to-new