Skip to content

Instantly share code, notes, and snippets.

@bmabey
Created July 21, 2010 22:38
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 bmabey/485247 to your computer and use it in GitHub Desktop.
Save bmabey/485247 to your computer and use it in GitHub Desktop.
*.sw?
classes
lib
*.jar
Trying to see if it is possible to have circular dependencies in clojure..
I don't think you can at this point, but I'd like to be proven wrong.
To test this out type "lein repl" and then "(require 'foo.core)". When I do this
I see "java.lang.Exception: No such var: foo.core/blah (bar.clj:5)" which
indicates a circular dependency (foo.core <--> foo.bar).
If you clone this gist you'll get a project to experiment in.
(ns foo.bar
(require foo.core))
(defn blah []
(foo.core/blah))
(defn baz []
(println "Coming from foo.bar/baz"))
(use 'clojure.contrib.with-ns)
(with-ns foo.bar
(declare baz))
(ns foo.core
(require foo.bar))
(defn blah []
(println "Coming from foo.core/blah"))
(defn baz []
(bar/baz))
(defproject foo "1.0.0-SNAPSHOT"
:description "FIXME: write"
:dependencies [[org.clojure/clojure "1.2.0-beta1"]
[org.clojure/clojure-contrib "1.2.0-beta1"]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment