Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable use-function-output-syntax for ISL[+]. Fixes #208. #229

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 2 additions & 0 deletions htdp-lib/lang/htdp-langs.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,7 @@
(language-numbers '(-500 -500 5))
(sharing-printing #t)
(abbreviate-cons-as-list #t)
(use-function-output-syntax? #t)
(allow-sharing? #t)
(reader-module '(lib "htdp-advanced-reader.ss" "lang"))
(debugger:supported #t)
Expand Down Expand Up @@ -1051,6 +1052,7 @@
(language-numbers '(-500 -500 4))
(sharing-printing #f)
(abbreviate-cons-as-list #t)
(use-function-output-syntax? #t)
(allow-sharing? #f)
(reader-module '(lib "htdp-intermediate-lambda-reader.ss" "lang"))
(stepper:supported #t)
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
14 changes: 12 additions & 2 deletions htdp-lib/lang/private/teach.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,14 @@
(define-for-syntax (stepper-ignore-checker stx)
(stepper-syntax-property stx 'stepper-skipto '(syntax-e cdr syntax-e cdr car)))


;; wrap-lambda-remove-name: syntax? -> syntax?
;; Removes source-location names for lambdas by erasing the source location
;; Preserves the lexical context, the syntax properties, but removes the source location
(define-for-syntax (wrap-lambda-remove-name stx)
(cond [(syntax-local-name) stx]
[else (datum->syntax stx (syntax-e stx) #f stx)]))

(define-for-syntax (map-with-index proc . lists)
(let loop ([i 0] [lists lists] [rev-result '()])
(if (null? (car lists))
Expand Down Expand Up @@ -2297,7 +2305,8 @@
stx
(syntax->list (syntax (lexpr ...)))
args)
(syntax/loc stx (lambda arg-seq lexpr ...)))]
(wrap-lambda-remove-name
(syntax/loc stx (lambda arg-seq lexpr ...))))]
;; Bad lambda because bad args:
[(_ args . __)
(teach-syntax-error
Expand Down Expand Up @@ -2504,7 +2513,8 @@
stx
(syntax->list (syntax exprs))
names)
(syntax/loc stx (lambda (name ...) . exprs)))]
(wrap-lambda-remove-name
(syntax/loc stx (lambda (name ...) . exprs))))]
[(_ args . __)
(teach-syntax-error
'lambda
Expand Down
5 changes: 0 additions & 5 deletions htdp-test/tests/htdp-lang/intm-lam.rktl
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
exn:fail:contract?
#rx"map: first argument must be a function that expects one argument"))

(htdp-err/rt-test (map (lambda (x y) (+ x y)) (list 2 3 4))
(exn-type-and-msg
exn:fail:contract?
#rx"intm-lam.rktl"))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This test has been moved to racket/drracket@4eaf30c.


(htdp-err/rt-test (foldr (lambda (x y) (+ x y)) 0 (list 2 3 4) (list 2 3 4))
(exn-type-and-msg
exn:fail:contract?
Expand Down
Loading