Created
May 22, 2018 18:59
-
-
Save pnwamk/9e9d30186d2af03de6b47f4155484adc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #lang racket/base | |
| (require (for-syntax racket/base)) | |
| (begin-for-syntax | |
| (struct env (types props aliases) #:transparent) | |
| (define lexical-env (make-parameter (env '() '() '())))) | |
| (define-syntax (LET stx) | |
| (syntax-case stx () | |
| [(_ ([x y]) bodies ...) | |
| (and (identifier? #'x) (identifier? #'y)) | |
| (parameterize ([lexical-env (struct-copy env (lexical-env) | |
| [aliases (cons (cons (syntax-e #'x) (syntax-e #'y)) | |
| (env-aliases (lexical-env)))])]) | |
| (local-expand #'(let ([x y]) bodies ...) 'expression '()))] | |
| [(_ ([x x-val]) bodies ...) | |
| (identifier? #'x) | |
| (parameterize ([lexical-env (struct-copy env (lexical-env) | |
| [types (cons (cons (syntax-e #'x) 'Any) | |
| (env-types (lexical-env)))])]) | |
| (local-expand #'(let ([x x-val]) bodies ...) 'expression '()))])) | |
| (define-syntax (trivial-print-env stx) | |
| (printf "env: ~a\n" (lexical-env)) | |
| #'(void)) | |
| (LET ([x 42]) | |
| (trivial-print-env) | |
| (LET ([y x]) | |
| (trivial-print-env) | |
| y)) | |
| #; | |
| (PRINT-ENV "FOO" | |
| (λ (thing/type-list) ;; (listof (cons any any)) | |
| blah) ;; either #f or (-> (listof (cons any any)) string?) | |
| (λ (list-of-props) ;; (listof any) | |
| blah) ;; either #f or (-> (listof any) string?) | |
| (λ (aliasing) ;; (listof (cons any any)) | |
| blah) ;; either #f or (-> (listof (cons any any)) string?) | |
| ) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment