Created
January 9, 2017 20:07
-
-
Save LeifAndersen/2271873c2be1faded947c2c5e47b5dd3 to your computer and use it in GitHub Desktop.
Paramters and Eval
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 | |
| (provide (struct-out foo) | |
| my-param) | |
| (require file/convertible) | |
| (define my-param (make-parameter "hello")) | |
| (struct foo () | |
| #:property prop:convertible | |
| (λ (s type default) | |
| (match type | |
| ['silly | |
| (my-param)] | |
| [_ default]))) | |
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 | |
| (require racket/sandbox | |
| file/convertible | |
| "a-file.rkt") | |
| (define my-eval | |
| (make-module-evaluator | |
| #:allow-for-require '("a-file.rkt") | |
| '(module foo racket | |
| (require "a-file.rkt") | |
| (define a-val (foo)) | |
| (provide a-val)))) | |
| (define that-val (my-eval 'a-val)) | |
| (parameterize ([my-param "hijacked..."]) | |
| (convert that-val 'silly)) | |
| (define that-other-val (foo)) | |
| (parameterize ([my-param "hijacked..."]) | |
| (convert that-other-val 'silly)) | |
| (module test racket | |
| (require "a-file.rkt") | |
| (provide another-val) | |
| (define another-val (foo))) | |
| (require 'test) | |
| (parameterize ([my-param "hijacked..."]) | |
| (convert another-val 'silly)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment