Skip to content

Commit

Permalink
Enable the use-function-output-syntax option for ISL and plus. Fixes
Browse files Browse the repository at this point in the history
…#208.

The printer for ISL, ISL+ and ASL relies on use-named/undefined-handler
and named/undefined-handler to correctly print named lambdas.
In particular, use-named/undefined-handler checks whether the option
use-function-output-syntax is set.

If use-function-output-syntax is not enabled, then 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 Nov 1, 2024
1 parent d9f49ec commit 2f91396
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions htdp-lib/htdp/bsl/runtime.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,11 @@
(and (sl-runtime-settings-use-function-output-syntax? settings)
(procedure? x)
(object-name x))))
;; The ISL case -- sl-runtime-settings-output-function-instead-of-lambda? --
;; is already covered by the current-print-convert-hook above.
(named/undefined-handler
(lambda (x)
(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
5 changes: 4 additions & 1 deletion htdp-lib/lang/private/teach-module-begin.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,14 @@
output-function-instead-of-lambda))
(mk-module-begin '(abbreviate-cons-as-list
read-accept-quasiquote
use-function-output-syntax
output-function-instead-of-lambda))
(mk-module-begin '(abbreviate-cons-as-list
read-accept-quasiquote))
read-accept-quasiquote
use-function-output-syntax))
(mk-module-begin '(abbreviate-cons-as-list
read-accept-quasiquote
use-function-output-syntax
show-sharing))

;; module-continue
Expand Down

0 comments on commit 2f91396

Please sign in to comment.