Skip to content

Instantly share code, notes, and snippets.

@mobius-eng
Last active January 19, 2016 20:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mobius-eng/72a73f6bd49bf5041591 to your computer and use it in GitHub Desktop.
Save mobius-eng/72a73f6bd49bf5041591 to your computer and use it in GitHub Desktop.
(define obj (make-top-level-environment))
(environment-define obj 'foo (lambda (x) (+ x bar)))
(environment-define obj 'bar 10)
((environment-lookup obj 'foo) 1)
; Unbound variable: bar
;; This works:
(define obj (extend-top-level-environment #f))
(eval '(define (foo x) (+ x bar)) obj)
(environment-define obj 'bar 10)
((environment-lookup obj 'foo) 1)
; 11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment