Skip to content

Commit

Permalink
Print functions as "function:f" instead of "function"
Browse files Browse the repository at this point in the history
... in BSL, BSL+, ISL.
  • Loading branch information
mikesperber committed Apr 16, 2023
1 parent 06e10ea commit 8a6d349
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 6 additions & 1 deletion htdp-lib/htdp/bsl/runtime.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@
(lambda (val basic sub)
(cond
[(and (sl-runtime-settings-output-function-instead-of-lambda? settings)
(procedure? val)) 'function]
(procedure? val))
(cond
((object-name val)
=> (lambda (name)
(string->symbol (format "function:~a" name))))
(else 'function))]
[(and (not (sl-runtime-settings-true/false/empty-as-ids? settings)) (equal? val '())) ''()]
[(equal? val set!-result) '(void)]
[(signature? val)
Expand Down
5 changes: 4 additions & 1 deletion htdp-lib/lang/private/signature-syntax.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,10 @@
(syntax-case stx ()
((_ ?name ?cnt ?expr)
(with-syntax ((?enforced
(stepper-syntax-property #'(attach-name '?name (apply-signature/blame ?cnt ?expr))
(stepper-syntax-property #'(attach-name '?name
(apply-signature/blame ?cnt
;; for reporting in signature violations
(attach-name '?name ?expr)))
'stepper-skipto/discard
;; apply-signature/blame takes care of itself
;; remember there's an implicit #%app
Expand Down

4 comments on commit 8a6d349

@mfelleisen
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good!

@shhyou
Copy link
Collaborator

@shhyou shhyou commented on 8a6d349 Oct 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In ISL+lambda, the output is just "f" (the name of the function), not "(lambda (a...) ...)" and not "function:f". Is this intended?

(But sure I can see an argument in favor of this behavior.)

@mfelleisen
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought so. (We should have a Redex model for *SL.)

@shhyou
Copy link
Collaborator

@shhyou shhyou commented on 8a6d349 Oct 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I agree that printing as just "f" is correct. I found out why I've had a different impression and reported it in #208.

Please sign in to comment.