-
-
Notifications
You must be signed in to change notification settings - Fork 102
Patched require/untyped-contract to accept a language spec. #1330
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
base: master
Are you sure you want to change the base?
Changes from 3 commits
78a113d
e79447f
6c91bf3
40b0fa5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,8 +29,8 @@ | |
(stx-map (lambda (id) ((make-syntax-introducer) id)) ids)) | ||
|
||
(define-syntax (require/untyped-contract stx) | ||
(syntax-parse stx #:literals (begin) | ||
[(_ (begin form ...) from-module-spec:expr [name:id T:expr] ...) | ||
(syntax-parse stx #:literals (begin quote) | ||
[(_ (begin form ...) from-module-spec:expr language-spec:id [name:id T:expr] ...) | ||
(with-syntax* ([(typed-name ...) (generate-temporaries #'(name ...))] | ||
[(untyped-name ...) (freshen #'(name ...))] | ||
[(untyped2-name ...) (generate-temporaries #'(name ...))] | ||
|
@@ -39,19 +39,18 @@ | |
[typed-module (generate-temporary #'typed-module)] | ||
[untyped-module (generate-temporary #'untyped-module)] | ||
[*racket/base (datum->syntax #'from-module-spec 'racket/base)] | ||
[*typed/racket/base (datum->syntax #'from-module-spec | ||
'typed/racket/base)] | ||
[*require (datum->syntax #'from-module-spec | ||
'require)] | ||
[*typed/racket (datum->syntax #'from-module-spec (syntax-e #'language-spec))] | ||
[*require (datum->syntax #'from-module-spec 'require)] | ||
[*language-spec (datum->syntax #'racket/base (syntax-e #'language-spec))] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @bennn Thanks for the feedback. I've changed the EDIT:As for the error about an Is there anything else I can do to improve this PR ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how about changing the syntax from |
||
[from-module-spec-for-submod | ||
(syntax-parse #'from-module-spec #:literals (submod) | ||
[(submod (~and base (~or "." "..")) elem ...) | ||
(syntax/loc #'from-module-spec (submod base ".." elem ...))] | ||
[x #'x])]) | ||
(syntax/loc stx | ||
(begin | ||
(module typed-module *typed/racket/base ; to bind in `T`s | ||
(*require typed/racket/base) ; to bind introduced `begin`, etc. | ||
(module typed-module *typed/racket ; to bind in `T`s | ||
(*require *language-spec) ; to bind introduced `begin`, etc. | ||
(begin form ...) | ||
(require (only-in from-module-spec-for-submod | ||
[name untyped2-name] ...)) | ||
|
@@ -70,5 +69,9 @@ | |
(define-typed/untyped-identifier macro-name typed-name untyped3-name) ...) | ||
|
||
(require (rename-in (submod "." untyped-module) [macro-name name] ...)))))] | ||
[(_ from-module-spec:expr language-spec:id [name:id T:expr] ...) | ||
(syntax/loc stx (require/untyped-contract (begin) from-module-spec language-spec [name T] ...))] | ||
[(_ (begin form ...) from-module-spec:expr [name:id T:expr] ...) | ||
(syntax/loc stx (require/untyped-contract (begin form ...) from-module-spec typed/racket/base [name T] ...))] | ||
[(_ from-module-spec:expr [name:id T:expr] ...) | ||
(syntax/loc stx (require/untyped-contract (begin) from-module-spec [name T] ...))])) | ||
(syntax/loc stx (require/untyped-contract (begin) from-module-spec typed/racket/base [name T] ...))])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep the indentation like it was