Skip to content

Commit

Permalink
Set current namespace to the current module. Fixes #208.
Browse files Browse the repository at this point in the history
The pconvert-lib printer checks the namespace for (pre-)defined symbols.

If the current namespace is not configured, as what would happen during module
instantiation, user-written functions like my-add1 would be printed differently.
This also affects the error message from the check-expects.

    #lang htdp/isl+
    (define (my-add1 n) (+ n 1))
    my-add1
    (check-expect my-add1 2)

Output:

    Welcome to DrRacket.
    (lambda (a1) ...)

    Ran 1 test.
    0 tests passed.

    check-expect ... error ... :: first argument of equality cannot
    be a function, given (lambda (a1) ...)

    > my-add1
    my-add1
  • Loading branch information
shhyou committed Oct 31, 2024
1 parent d9f49ec commit 6674ca6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions htdp-lib/htdp/bsl/runtime.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,14 @@
[else (ph val basic sub)]))))
(use-named/undefined-handler
(lambda (x)
(and (sl-runtime-settings-use-function-output-syntax? settings)
(procedure? x)
(and (procedure? x)
(object-name x))))
(named/undefined-handler
(lambda (x)
(string->symbol
(format "function:~a" (object-name x)))))
(if (sl-runtime-settings-output-function-instead-of-lambda? settings)
(string->symbol
(format "function:~a" (object-name x)))
(object-name x))))

; sharing done by print-convert
(show-sharing (sl-runtime-settings-show-sharing? settings))
Expand Down

0 comments on commit 6674ca6

Please sign in to comment.