Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Templates inherit thread bindings when created #30

Closed
Raynes opened this issue Feb 13, 2012 · 3 comments
Closed

Templates inherit thread bindings when created #30

Raynes opened this issue Feb 13, 2012 · 3 comments

Comments

@Raynes
Copy link

Raynes commented Feb 13, 2012

I ran into a bug today where templates created with deftemplate seem to behave as if created with bound-fn.

Take this example:

(def ^{:dynamic true} *foo*) 
(defn x [] (prn *foo*)) 
(binding [*foo* "foo"] (x))

This has the effect of printing "foo" because when x is called, the binding sets the value of *foo*. If you replace x with a deftemplate, *foo* is unbound and doesn't get the bindings.

I'm actually pretty shocked that I'm the only one who has noticed this after all this time. This makes Enlive pretty hard to use with Noir and Sandbar because their stateful sessions use bindings to reflect the current session. I'm stuck on moving RefHeap to Enlive because I don't want to delve into the major hax that'd be involved in working around this.

Also, is this project going to be actively maintained in the future? I see there are some pull requests and issues that have been festering for a year or longer. They don't really inspire confidence. :p

cgrand added a commit that referenced this issue Feb 19, 2012
@cgrand
Copy link
Owner

cgrand commented Feb 19, 2012

fixed by the above commit.

@cgrand cgrand closed this as completed Feb 19, 2012
@solussd
Copy link

solussd commented Jun 8, 2012

then, in the future, I had a "wtf?" moment with this. :D Thanks for the fix.

@yuanmai
Copy link

yuanmai commented Jan 27, 2013

clone-for still has the same problem:

(deftemplate ...
  (clone-for [x *foo*]
))

I can access foo outside of clone-for, but inside clone-for, foo is always bound to the initial value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants