Make the Stepper behavior on and/or configurable:
In the HtDP languages, initial subexpressions that have evaluated to #t / #f remain in the residual term, whereas in the DMdA languages, they do not. svn: r16018
This commit is contained in:
parent
11c6d0ac9b
commit
c26b3b8c6c
|
@ -1087,6 +1087,7 @@
|
||||||
(init-field stepper:supported)
|
(init-field stepper:supported)
|
||||||
(define/override (stepper:supported?) stepper:supported)
|
(define/override (stepper:supported?) stepper:supported)
|
||||||
(define/override (stepper:show-inexactness?) #f)
|
(define/override (stepper:show-inexactness?) #f)
|
||||||
|
(define/override (stepper:show-consumed-and/or-clauses?) #f)
|
||||||
(define/override (stepper:render-to-sexp val settings language-level)
|
(define/override (stepper:render-to-sexp val settings language-level)
|
||||||
(parameterize ([pc:current-print-convert-hook (make-print-convert-hook settings)])
|
(parameterize ([pc:current-print-convert-hook (make-print-convert-hook settings)])
|
||||||
(set-print-settings
|
(set-print-settings
|
||||||
|
|
|
@ -8,4 +8,6 @@
|
||||||
stepper:supported?
|
stepper:supported?
|
||||||
stepper:enable-let-lifting?
|
stepper:enable-let-lifting?
|
||||||
stepper:show-lambdas-as-lambdas?
|
stepper:show-lambdas-as-lambdas?
|
||||||
|
stepper:show-inexactness?
|
||||||
|
stepper:show-consumed-and/or-clauses?
|
||||||
stepper:render-to-sexp)))
|
stepper:render-to-sexp)))
|
||||||
|
|
|
@ -274,17 +274,19 @@
|
||||||
|
|
||||||
(define ((unwind-and/or label) stx settings)
|
(define ((unwind-and/or label) stx settings)
|
||||||
(let ([user-source (syntax-property stx 'user-source)]
|
(let ([user-source (syntax-property stx 'user-source)]
|
||||||
[user-position (syntax-property stx 'user-position)]
|
[user-position (syntax-property stx 'user-position)])
|
||||||
[clause-padder
|
|
||||||
(if (render-settings-true-false-printed? settings)
|
|
||||||
(case label [(and) #'true] [(or) #'false])
|
|
||||||
(case label [(and) #'#t] [(or) #'#f]))])
|
|
||||||
(with-syntax
|
(with-syntax
|
||||||
([clauses
|
([clauses
|
||||||
(append
|
(append
|
||||||
(build-list (stepper-syntax-property
|
(if (render-settings-show-and/or-clauses-consumed? settings)
|
||||||
stx 'stepper-and/or-clauses-consumed)
|
(build-list (stepper-syntax-property
|
||||||
(lambda (dc) clause-padder))
|
stx 'stepper-and/or-clauses-consumed)
|
||||||
|
(let ([clause-padder
|
||||||
|
(if (render-settings-true-false-printed? settings)
|
||||||
|
(case label [(and) #'true] [(or) #'false])
|
||||||
|
(case label [(and) #'#t] [(or) #'#f]))])
|
||||||
|
(lambda (dc) clause-padder)))
|
||||||
|
'())
|
||||||
(let loop ([stx stx])
|
(let loop ([stx stx])
|
||||||
(if (and (eq? user-source
|
(if (and (eq? user-source
|
||||||
(syntax-property stx 'user-source))
|
(syntax-property stx 'user-source))
|
||||||
|
|
|
@ -16,8 +16,14 @@
|
||||||
; the reconstructor gets the right invocation of the unit, it needs to be a
|
; the reconstructor gets the right invocation of the unit, it needs to be a
|
||||||
; unit as well. Pretty soon, everything is units.
|
; unit as well. Pretty soon, everything is units.
|
||||||
|
|
||||||
(define-struct render-settings (true-false-printed? constructor-style-printing? abbreviate-cons-as-list? render-to-sexp lifting?
|
(define-struct render-settings
|
||||||
all-bindings-mutable?))
|
(true-false-printed?
|
||||||
|
constructor-style-printing?
|
||||||
|
abbreviate-cons-as-list?
|
||||||
|
render-to-sexp
|
||||||
|
lifting?
|
||||||
|
show-and/or-clauses-consumed?
|
||||||
|
all-bindings-mutable?))
|
||||||
|
|
||||||
(provide/contract [check-global-defined (-> symbol? boolean?)]
|
(provide/contract [check-global-defined (-> symbol? boolean?)]
|
||||||
[global-lookup (-> any/c any)]
|
[global-lookup (-> any/c any)]
|
||||||
|
@ -28,6 +34,7 @@
|
||||||
[abbreviate-cons-as-list? boolean?]
|
[abbreviate-cons-as-list? boolean?]
|
||||||
[render-to-sexp (any/c . -> . any)]
|
[render-to-sexp (any/c . -> . any)]
|
||||||
[lifting? boolean?]
|
[lifting? boolean?]
|
||||||
|
[show-and/or-clauses-consumed? boolean?]
|
||||||
[all-bindings-mutable? boolean?])]
|
[all-bindings-mutable? boolean?])]
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,6 +42,7 @@
|
||||||
[get-render-settings ((any/c . -> . string?) ; render-to-string
|
[get-render-settings ((any/c . -> . string?) ; render-to-string
|
||||||
(any/c . -> . any) ; render-to-sexp
|
(any/c . -> . any) ; render-to-sexp
|
||||||
boolean? ; lifting?
|
boolean? ; lifting?
|
||||||
|
boolean? ; show-and/or-clauses-consumed?
|
||||||
. -> .
|
. -> .
|
||||||
render-settings?)]
|
render-settings?)]
|
||||||
|
|
||||||
|
@ -59,10 +67,10 @@
|
||||||
|
|
||||||
; FIXME : #f totally unacceptable as 'render-to-string'
|
; FIXME : #f totally unacceptable as 'render-to-string'
|
||||||
(define fake-beginner-render-settings
|
(define fake-beginner-render-settings
|
||||||
(make-render-settings #t #t #f (make-fake-render-to-sexp #t #t #f) #t #f))
|
(make-render-settings #t #t #f (make-fake-render-to-sexp #t #t #f) #t #t #f))
|
||||||
|
|
||||||
(define fake-beginner-wla-render-settings
|
(define fake-beginner-wla-render-settings
|
||||||
(make-render-settings #t #t #t (make-fake-render-to-sexp #t #t #t) #t #f))
|
(make-render-settings #t #t #t (make-fake-render-to-sexp #t #t #t) #t #t #f))
|
||||||
|
|
||||||
(define fake-intermediate-render-settings
|
(define fake-intermediate-render-settings
|
||||||
fake-beginner-wla-render-settings)
|
fake-beginner-wla-render-settings)
|
||||||
|
@ -80,13 +88,14 @@
|
||||||
(abbreviate-cons-as-list)
|
(abbreviate-cons-as-list)
|
||||||
print-convert
|
print-convert
|
||||||
#f
|
#f
|
||||||
#f))
|
#t
|
||||||
|
#f))
|
||||||
|
|
||||||
(define-struct test-struct () (make-inspector))
|
(define-struct test-struct () (make-inspector))
|
||||||
|
|
||||||
;; get-render-settings : infer aspects of the current language's print conversion by explicitly testing
|
;; get-render-settings : infer aspects of the current language's print conversion by explicitly testing
|
||||||
;; assorted test expressions
|
;; assorted test expressions
|
||||||
(define (get-render-settings render-to-string render-to-sexp lifting?)
|
(define (get-render-settings render-to-string render-to-sexp lifting? show-and/or-clauses-consumed?)
|
||||||
(let* ([true-false-printed? (string=? (render-to-string #t) "true")]
|
(let* ([true-false-printed? (string=? (render-to-string #t) "true")]
|
||||||
[constructor-style-printing? (string=? (render-to-string (make-test-struct)) "(make-test-struct)")]
|
[constructor-style-printing? (string=? (render-to-string (make-test-struct)) "(make-test-struct)")]
|
||||||
[rendered-list (render-to-string '(3))]
|
[rendered-list (render-to-string '(3))]
|
||||||
|
@ -101,6 +110,7 @@
|
||||||
abbreviate-cons-as-list?
|
abbreviate-cons-as-list?
|
||||||
render-to-sexp
|
render-to-sexp
|
||||||
lifting?
|
lifting?
|
||||||
|
show-and/or-clauses-consumed?
|
||||||
#f)))
|
#f)))
|
||||||
|
|
||||||
(define (check-global-defined identifier)
|
(define (check-global-defined identifier)
|
||||||
|
|
|
@ -36,6 +36,9 @@
|
||||||
(public stepper:show-inexactness?)
|
(public stepper:show-inexactness?)
|
||||||
(define (stepper:show-inexactness?) #t)
|
(define (stepper:show-inexactness?) #t)
|
||||||
|
|
||||||
|
(public stepper:show-consumed-and/or-clauses?)
|
||||||
|
(define (stepper:show-consumed-and/or-clauses?) #t)
|
||||||
|
|
||||||
(public stepper:render-to-sexp)
|
(public stepper:render-to-sexp)
|
||||||
(define (stepper:render-to-sexp val settings language-level)
|
(define (stepper:render-to-sexp val settings language-level)
|
||||||
(parameterize ([pretty-print-show-inexactness (stepper:show-inexactness?)]
|
(parameterize ([pretty-print-show-inexactness (stepper:show-inexactness?)]
|
||||||
|
|
|
@ -390,7 +390,8 @@
|
||||||
(model:go
|
(model:go
|
||||||
program-expander-prime receive-result
|
program-expander-prime receive-result
|
||||||
(get-render-settings render-to-string render-to-sexp
|
(get-render-settings render-to-string render-to-sexp
|
||||||
(send language-level stepper:enable-let-lifting?))
|
(send language-level stepper:enable-let-lifting?)
|
||||||
|
(send language-level stepper:show-consumed-and/or-clauses?))
|
||||||
(send language-level stepper:show-lambdas-as-lambdas?)
|
(send language-level stepper:show-lambdas-as-lambdas?)
|
||||||
language-level
|
language-level
|
||||||
run-on-drscheme-side
|
run-on-drscheme-side
|
||||||
|
|
Loading…
Reference in New Issue
Block a user