Interesting results.

By putting (println compiled-ops) it worked, but not by putting it in
a doall. (same error)

Changing my declares to defs did the trick did though and learning
about bound-fn* was also a serious mind-expander for me right now too.

Thanks to both of you!

On Sep 6, 4:57 pm, Jarkko Oranen <chous...@gmail.com> wrote:
> Cameron Pulsford wrote:
> > 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)))
>
> Your problem is that compiled-ops is a lazy sequence, and it only gets
> realised when it's used, which probably happens after it has exited
> the dynamic scope where *macros* is bound.
>
> You can work around the problem by forcing the sequence with doall or
> by using bound-fn* to save the dynamic environment (ie. (map (bound-
> fn* compile-op) fns), though double check that from the docs)

-- 
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