Skip to content

Instantly share code, notes, and snippets.

@semperos
Created November 4, 2014 17:43
Show Gist options
  • Select an option

  • Save semperos/5d2e8fdd3ad87087b793 to your computer and use it in GitHub Desktop.

Select an option

Save semperos/5d2e8fdd3ad87087b793 to your computer and use it in GitHub Desktop.
Var's in fn's
#_user=> (defn init [] (def foo 42) (def bar 21))
;=> #'user/init
#_user=> (ns new-ns (:require user))
;=> nil
#_new-ns=> (user/init)
;=> #'user/bar
#_new-ns=> foo
; CompilerException java.lang.RuntimeException: Unable to resolve symbol: foo in this context, compiling:(/private/var/folders/nv/qqtdn92n2hzb30fp95xytks80000gp/T/form-init2636843255245152689.clj:1:4154)
#_new-ns=> bar
; CompilerException java.lang.RuntimeException: Unable to resolve symbol: bar in this context, compiling:(/private/var/folders/nv/qqtdn92n2hzb30fp95xytks80000gp/T/form-init2636843255245152689.clj:1:4154)
#_new-ns=> user/foo
;=> 42
#_new-ns=> user/bar
;=> 21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment