Skip to content

Commit d02f7bc

Browse files
resyntax-ci[bot]rfindler
authored andcommitted
Fix 4 occurrences of let-to-define
Internal definitions are recommended instead of `let` expressions, to reduce nesting.
1 parent 0977dc2 commit d02f7bc

2 files changed

Lines changed: 33 additions & 35 deletions

File tree

drracket-core-lib/drracket/private/get-defs.rkt

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -158,19 +158,17 @@
158158
;; get-defn-indent : text number -> number
159159
;; returns the amount to indent a particular definition
160160
(define (get-defn-indent text pos)
161-
(let* ([para (send text position-paragraph pos)]
162-
[para-start (send text paragraph-start-position para #t)])
163-
(let loop ([c-pos para-start]
164-
[offset 0])
165-
(cond
166-
[(< c-pos pos)
167-
(define char (send text get-character c-pos))
168-
(cond
169-
[(char=? char #\tab)
170-
(loop (+ c-pos 1) (+ offset (- 8 (modulo offset 8))))]
171-
[else
172-
(loop (+ c-pos 1) (+ offset 1))])]
173-
[else offset]))))
161+
(define para (send text position-paragraph pos))
162+
(define para-start (send text paragraph-start-position para #t))
163+
(let loop ([c-pos para-start]
164+
[offset 0])
165+
(cond
166+
[(< c-pos pos)
167+
(define char (send text get-character c-pos))
168+
(cond
169+
[(char=? char #\tab) (loop (+ c-pos 1) (+ offset (- 8 (modulo offset 8))))]
170+
[else (loop (+ c-pos 1) (+ offset 1))])]
171+
[else offset])))
174172

175173
;; whitespace-or-paren?
176174
(define (whitespace-or-paren? char)

drracket-core-lib/drracket/private/syncheck-debug.rkt

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -121,24 +121,24 @@
121121
(define (syntax-object->datum/ht stx)
122122
(define ht (make-hasheq))
123123
(values (let loop ([stx stx])
124-
(let ([obj (syntax-e stx)])
125-
(cond
126-
[(list? obj)
127-
(let ([res (map loop obj)])
128-
(hash-set! ht res stx)
129-
res)]
130-
[(pair? obj)
131-
(let ([res (cons (loop (car obj)) (loop (cdr obj)))])
132-
(hash-set! ht res stx)
133-
res)]
134-
[(vector? obj)
135-
(let ([res (list->vector (map loop (vector->list obj)))])
136-
(hash-set! ht res stx)
137-
res)]
138-
[else
139-
(let ([res (syntax->datum stx)])
140-
(hash-set! ht res stx)
141-
res)])))
124+
(define obj (syntax-e stx))
125+
(cond
126+
[(list? obj)
127+
(let ([res (map loop obj)])
128+
(hash-set! ht res stx)
129+
res)]
130+
[(pair? obj)
131+
(let ([res (cons (loop (car obj)) (loop (cdr obj)))])
132+
(hash-set! ht res stx)
133+
res)]
134+
[(vector? obj)
135+
(let ([res (list->vector (map loop (vector->list obj)))])
136+
(hash-set! ht res stx)
137+
res)]
138+
[else
139+
(let ([res (syntax->datum stx)])
140+
(hash-set! ht res stx)
141+
res)]))
142142
ht))
143143

144144
;; make-text-port : text -> port
@@ -147,8 +147,8 @@
147147
(define-values (in out) (make-pipe))
148148
(thread (λ ()
149149
(let loop ()
150-
(let ([c (read-char in)])
151-
(unless (eof-object? c)
152-
(send text insert (string c) (send text last-position) (send text last-position))
153-
(loop))))))
150+
(define c (read-char in))
151+
(unless (eof-object? c)
152+
(send text insert (string c) (send text last-position) (send text last-position))
153+
(loop)))))
154154
out)

0 commit comments

Comments
 (0)