Skip to content

Instantly share code, notes, and snippets.

@LeifAndersen
Created January 9, 2017 20:07
Show Gist options
  • Select an option

  • Save LeifAndersen/2271873c2be1faded947c2c5e47b5dd3 to your computer and use it in GitHub Desktop.

Select an option

Save LeifAndersen/2271873c2be1faded947c2c5e47b5dd3 to your computer and use it in GitHub Desktop.
Paramters and Eval
#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])))
#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