-
-
Notifications
You must be signed in to change notification settings - Fork 97
Automated Resyntax fixes #792
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
These list element variable definitions can be expressed more succinctly with `match-define`. Note that the suggested replacement raises an error if the list contains more elements than expected.
The `begin` in this definition can be extracted into the surrounding definition context.
This `for-each` operation can be replaced with a `for` loop.
Internal definitions are recommended instead of `let` expressions, to reduce nesting.
Using `cond` allows converting `let` to internal definitions, reducing nesting
970d30f to
c89f9a3
Compare
|
I rebased on master and just dropped commits that had conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resyntax analyzed 3 files in this pull request and has added suggestions.
| (let ([res (syntax->datum stx)]) | ||
| (hash-set! ht res stx) | ||
| res)])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cond-let-to-cond-define: Internal definitions are recommended instead of let expressions, to reduce nesting.
| (let ([res (syntax->datum stx)]) | |
| (hash-set! ht res stx) | |
| res)])) | |
| (define res (syntax->datum stx)) | |
| (hash-set! ht res stx) | |
| res])) |
Debugging details
Textual replacement
(line-replacement
#:new-lines
'#(" (define res (syntax->datum stx))"
" (hash-set! ht res stx)"
" res]))")
#:original-lines
'#(" (let ([res (syntax->datum stx)])"
" (hash-set! ht res stx)"
" res)]))")
#:start-line 139)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:36:2 (cond ((list? obj) (let ((res (map loop obj))) (hash-set! ht res stx) res)) ((pair? obj) (let ((res (cons (loop (car obj)) (loop (cdr obj))))) (hash-set! ht res stx) res)) ((vector? obj) (let ((res (list->vector (map loop (vector->list obj))))) (hash-se...>
#:original-syntax
#<syntax:drracket-core-lib/drracket/private/syncheck-debug.rkt:125:14 (cond ((list? obj) (let ((res (map loop obj))) (hash-set! ht res stx) res)) ((pair? obj) (let ((res (cons (loop (car obj)) (loop (cdr obj))))) (hash-set! ht res stx) res)) ((vector? obj) (let ((res (list->vector (map loop (vector->list obj))))) (hash-se...>
#:source
(file-source
#<path:/home/runner/work/drracket/drracket/drracket-core-lib/drracket/private/syncheck-debug.rkt>)
#:uses-universal-tagged-syntax? #f)
Resyntax fixed 20 issues in 7 files.
unless-expression-in-for-loop-to-unless-keywordlet-to-definelist-element-definitions-to-match-definefor-each-to-formap-to-forwhen-expression-in-for-loop-to-when-keywordand-let-to-condnamed-let-loop-to-for-in-rangedefine-begin-extraction