[racket] Scribbling HTDP

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Mon Feb 27 10:59:47 EST 2012

Why is make-evaluator insufficient?

On Mon, Feb 27, 2012 at 9:55 AM, Matthias Felleisen
<matthias at ccs.neu.edu> wrote:
>
> I was wrong. The code below accomplishes what you want. It sets up an evaluator in the *sl languages, including hooks to print #t and #f properly.
>
> (Matthew reminded me but I had to re-run the rendering script in a clean directory to validate his reminder.)
>
>
>
> (define-syntax-rule
>  (*sl-eval module-lang reader def ...)
>  ;; ===>>>
>  (let ()
>    (define me (make-base-eval))
>    (me '(require (only-in racket empty? first rest cons? sqr true false)))
>    (me '(require lang/posn))
>    (me '(require racket/pretty))
>    (me '(current-print pretty-print-handler))
>    (me '(pretty-print-columns 65))
>    (me 'def)
>    ...
>    (call-in-sandbox-context me (lambda () (error-print-source-location #f)))
>    (call-in-sandbox-context me (lambda ()
>                                  (current-print-convert-hook
>                                    (let ([prev (current-print-convert-hook)])
>                                      ;; tell `print-convert' to leave images as themselves:
>                                      (lambda (v basic sub)
>                                        (if (convertible? v)
>                                            v
>                                            (prev v basic sub)))))
>
>                                  (pretty-print-size-hook
>                                    (let ([prev (pretty-print-size-hook)])
>                                      ;; tell `pretty-print' that we'll handle images specially:
>                                      (lambda (v w? op)
>                                        (if (convertible? v) 1 (prev v w? op)))))
>
>                                  (pretty-print-print-hook
>                                    (let ([prev (pretty-print-print-hook)])
>                                      ;; tell `pretty-print' how to handle images, which is
>                                      ;; by using `write-special':
>                                      (lambda (v w? op)
>                                        (if (convertible? v) (write-special v op) (prev v w? op)))))
>
>                                  ((dynamic-require 'htdp/bsl/runtime 'configure)
>                                   (dynamic-require reader 'options))))
>    (call-in-sandbox-context me (lambda () (namespace-require module-lang)))
>    (interaction-eval #:eval me (require 2htdp/image))
>    (interaction-eval #:eval me (require 2htdp/batch-io))
>    ;; --- splice in the defs
>    me))
>
> (define-syntax-rule
>  (bsl-eval def ...)
>  (*sl-eval 'lang/htdp-beginner 'htdp/bsl/lang/reader def ...))
>
> (define-syntax-rule
>  (bsl-eval+ def ...)
>  (*sl-eval 'lang/htdp-beginner-abbr 'htdp/bsl+/lang/reader def ...))
>
> (define-syntax-rule
>  (isl-eval def ...)
>  (*sl-eval 'lang/htdp-intermediate 'htdp/isl/lang/reader def ...))
>
> (define-syntax-rule
>  (isl-eval+ def ...)
>  (*sl-eval 'lang/htdp-intermediate-lambda 'htdp/isl/lang/reader def ...))
>
>
>
>
>
> On Feb 27, 2012, at 10:31 AM, Robby Findler wrote:
>
>> Should consider this a bug (that that the call to make-evaluator below
>> doesn't set things up properly for this usecase)?
>>
>> Robby
>>
>> On Mon, Feb 27, 2012 at 9:27 AM, Matthias Felleisen
>> <matthias at ccs.neu.edu> wrote:
>>>
>>> I am running a short filter function on the output that changes #t to true. -- Matthias
>>>
>>>
>>>
>>> On Feb 27, 2012, at 10:23 AM, Klaus Ostermann wrote:
>>>
>>>> Hi all,
>>>>
>>>> I want to use Scribble for some lecture notes using HTDP/2e.
>>>>
>>>> The example "An Introduction to Racket with Pictures" illustrates how to use Scribble and embed Racket evaluation. However, the HTDP
>>>> languages behave different in some ways - for instance, they
>>>> print "#t" as "true" and various other differences.
>>>>
>>>> How can I use Scribble to write about examples in the HTDP languages?
>>>> I want the exact behavior of the HTDP languages. Using, say,
>>>> (make-evaluator 'lang/htdp-intermediate)
>>>> is not sufficient.
>>>>
>>>> HTDP/2e itself seems to be written using Scribble, which would mean that there is already a solution to this problem (?).
>>>>
>>>> Regards,
>>>> Klaus
>>>> ____________________
>>>> Racket Users list:
>>>> http://lists.racket-lang.org/users
>>>
>>>
>>> ____________________
>>>  Racket Users list:
>>>  http://lists.racket-lang.org/users
>
>
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users


Posted on the users mailing list.