Hello all, here is an extremely reduced version of a problem I'm not
sure how to work around. (It's going to be a toy assembly language if
anyone's wondering) When I call assemble in the following code I get
the error: "java.lang.IllegalStateException: Var reader/*macros* is
unbound." I'd like *macros* to always be rebound for whatever source
file is being compiled and I'd rather not explicitly pass the map of
macros (and other things not shown here) to every function in the
hierarchy just to supply some of the bottom level worker functions
with the information they need.

Is there a way to do this? Besides cleaning up function signatures is
this a premature optimization to begin with?

(declare *macros*)

(defn macro-expand [tokens]
  (map #(get *macros* % %) tokens))

(defn compile-op [op]
  (macro-expand op))

(defn assemble [{:keys [macros syms blks fncs]}]
  (binding [*macros* macros] ;; I thought binding would handle this,
but I must be misusing it
    (let [compiled-ops (map compile-op fncs)]
      compiled-ops)))



-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to